wip
This commit is contained in:
parent
73e2459342
commit
ac03089c25
|
@ -63,6 +63,11 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: BaseTower
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: eb5e13df78999ef878da1db5c63224e2,
|
||||
type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 8
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects:
|
||||
- {fileID: -3133498875991405556, guid: eb5e13df78999ef878da1db5c63224e2, type: 3}
|
||||
|
|
|
@ -11,7 +11,7 @@ GameObject:
|
|||
- component: {fileID: 6791947043022790992}
|
||||
- component: {fileID: 283773815913351468}
|
||||
- component: {fileID: 7403195583508196174}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Sphere
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -94,7 +94,7 @@ GameObject:
|
|||
- component: {fileID: 5119260969314287638}
|
||||
- component: {fileID: 6992152662476368078}
|
||||
- component: {fileID: 8324639096253395440}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Cylinder.002
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
|
|
@ -11,7 +11,7 @@ GameObject:
|
|||
- component: {fileID: 7260327517591084354}
|
||||
- component: {fileID: 5566712258885047037}
|
||||
- component: {fileID: 3451839468339987846}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Base
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -96,7 +96,7 @@ GameObject:
|
|||
- component: {fileID: 3688593234855359137}
|
||||
- component: {fileID: 7215452495559205732}
|
||||
- component: {fileID: 8981486734084153558}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: HorizontalArc
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -252,7 +252,7 @@ GameObject:
|
|||
- component: {fileID: 432796252682377629}
|
||||
- component: {fileID: 3370533879401949812}
|
||||
- component: {fileID: 1398471167256814047}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: SliderKnob
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -367,7 +367,7 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3410229124093629554}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Tip
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -402,7 +402,7 @@ GameObject:
|
|||
- component: {fileID: 271800776993535811}
|
||||
- component: {fileID: 1616640625290415239}
|
||||
- component: {fileID: 8756968480882234867}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: SliderKnob
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -508,37 +508,6 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 9998882d4b72010a9b0ca2d8bd35835e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &3857615556319596175
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2164222606230954140}
|
||||
m_Layer: 0
|
||||
m_Name: Tip
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2164222606230954140
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3857615556319596175}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0, y: 0, z: 0.00771}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 9116936080776508834}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &7405500333329299342
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -551,7 +520,7 @@ GameObject:
|
|||
- component: {fileID: 1325528991062417693}
|
||||
- component: {fileID: 7013367250967747671}
|
||||
- component: {fileID: 2740722787380423134}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: Barrel
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -649,7 +618,7 @@ GameObject:
|
|||
- component: {fileID: 4508182228569071021}
|
||||
- component: {fileID: 1366289561210151836}
|
||||
- component: {fileID: 5247639431516572416}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: VerticalArc
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -802,7 +771,7 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 2141594701022449211}
|
||||
- component: {fileID: 3987931586699850031}
|
||||
m_Layer: 0
|
||||
m_Layer: 8
|
||||
m_Name: TrajectoryLine
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
|
@ -1057,10 +1026,6 @@ PrefabInstance:
|
|||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 3688593234855359137}
|
||||
- targetCorrespondingSourceObject: {fileID: 527409087646353271, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 2164222606230954140}
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 872127579833310669, guid: f54a14318952c90c5b47a300aedb0d15,
|
||||
type: 3}
|
||||
|
|
|
@ -7,6 +7,7 @@ public class CameraSlotClickDetect : MonoBehaviour
|
|||
{
|
||||
public Camera mainCamera;
|
||||
public LayerMask layerMask;
|
||||
public LayerMask selectLayer;
|
||||
|
||||
private SlotManager PrevHoveredSlot;
|
||||
|
||||
|
@ -30,6 +31,12 @@ public class CameraSlotClickDetect : MonoBehaviour
|
|||
var slotInfo = hit.collider.gameObject.GetComponentInParent<SlotManager>();
|
||||
slotInfo.OnClick();
|
||||
}
|
||||
RaycastHit selectHit;
|
||||
if (Physics.Raycast(ray, out selectHit, Mathf.Infinity, selectLayer))
|
||||
{
|
||||
var obj = selectHit.collider.gameObject.GetComponentInChildren<Tower>();
|
||||
obj.TowerSelected.Value = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ShootHoverRay()
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
@ -24,7 +25,6 @@ public class AimTower : Tower
|
|||
public float HorizontalRotation => horizontalArc.Value;
|
||||
public float VerticalRotation => verticalArc.Value;
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
horizontalArc.Value.AddListener(UpdateBarrelRotation);
|
||||
|
@ -35,8 +35,18 @@ public class AimTower : Tower
|
|||
|
||||
horizontalArc.Value.AddListener(SnapVerticalToHorizontal);
|
||||
|
||||
TowerSelected.AddListener(OnTowerSelected);
|
||||
|
||||
UpdateBarrelRotation();
|
||||
UpdateTrajectory();
|
||||
OnTowerSelected(TowerSelected);
|
||||
}
|
||||
|
||||
private void OnTowerSelected(bool selected)
|
||||
{
|
||||
horizontalArc.enabled = selected;
|
||||
verticalArc.enabled = selected;
|
||||
trajectoryLine.enabled = selected;
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
|
@ -68,6 +78,8 @@ public class AimTower : Tower
|
|||
ghost.SetActive(false);
|
||||
}
|
||||
|
||||
if (!TowerSelected.Value) return;
|
||||
|
||||
Vector3 origin = barrel.Tip.position;
|
||||
Vector3 dir = barrel.transform.forward;
|
||||
List<Vector3> pointsInTrajectory = new();
|
||||
|
@ -84,7 +96,6 @@ public class AimTower : Tower
|
|||
origin = hit.point;
|
||||
}
|
||||
|
||||
|
||||
trajectoryLine.positionCount = pointsInTrajectory.Count;
|
||||
trajectoryLine.SetPositions(pointsInTrajectory.ToArray());
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Projectile : MonoBehaviour
|
|||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
HealthComponent hitHealthComp = collision.gameObject.GetComponent<HealthComponent>();
|
||||
if (hitHealthComp == comingFrom) return;
|
||||
// if (hitHealthComp == comingFrom) return;
|
||||
if (hitHealthComp)
|
||||
{
|
||||
hitHealthComp.TakeDamage(damage);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
public abstract class Tower : MonoBehaviour
|
||||
{
|
||||
public bool towerSelected { get; set; } = true;
|
||||
public Observer<bool> TowerSelected { get; set; } = new(false);
|
||||
|
||||
protected HealthComponent healthComp;
|
||||
|
||||
|
@ -13,8 +14,20 @@ public abstract class Tower : MonoBehaviour
|
|||
{
|
||||
healthComp = GetComponent<HealthComponent>();
|
||||
Assert.IsNotNull(healthComp);
|
||||
|
||||
TowerSelected.AddListener(DeselectTowers);
|
||||
}
|
||||
|
||||
public static void DeselectTowers(bool selected)
|
||||
{
|
||||
if (selected)
|
||||
{
|
||||
foreach (var tower in GameObject.FindObjectsByType<Tower>(FindObjectsSortMode.None))
|
||||
{
|
||||
tower.TowerSelected.Value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue