Compare commits

..

No commits in common. "9ad8d6ee3e1e2ccd0d22823332ece506c7235ee2" and "236e529d6df4bd5b5a7df8443c2bd91908f03f39" have entirely different histories.

8 changed files with 50 additions and 52 deletions

View File

@ -63,11 +63,6 @@ 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}

View File

@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 6791947043022790992}
- component: {fileID: 283773815913351468}
- component: {fileID: 7403195583508196174}
m_Layer: 8
m_Layer: 0
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: 8
m_Layer: 0
m_Name: Cylinder.002
m_TagString: Untagged
m_Icon: {fileID: 0}

View File

@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 7260327517591084354}
- component: {fileID: 5566712258885047037}
- component: {fileID: 3451839468339987846}
m_Layer: 8
m_Layer: 0
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: 8
m_Layer: 0
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: 8
m_Layer: 0
m_Name: SliderKnob
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -367,7 +367,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 3410229124093629554}
m_Layer: 8
m_Layer: 0
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: 8
m_Layer: 0
m_Name: SliderKnob
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -508,6 +508,37 @@ 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
@ -520,7 +551,7 @@ GameObject:
- component: {fileID: 1325528991062417693}
- component: {fileID: 7013367250967747671}
- component: {fileID: 2740722787380423134}
m_Layer: 8
m_Layer: 0
m_Name: Barrel
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -618,7 +649,7 @@ GameObject:
- component: {fileID: 4508182228569071021}
- component: {fileID: 1366289561210151836}
- component: {fileID: 5247639431516572416}
m_Layer: 8
m_Layer: 0
m_Name: VerticalArc
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -771,7 +802,7 @@ GameObject:
m_Component:
- component: {fileID: 2141594701022449211}
- component: {fileID: 3987931586699850031}
m_Layer: 8
m_Layer: 0
m_Name: TrajectoryLine
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -1026,6 +1057,10 @@ 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}

View File

@ -7,9 +7,8 @@ public class GameManager : MonoBehaviour
public static GameManager Instance;
public bool IsBuildMode = false;
public Tower SelectedTower;
private void Awake()
private void Start()
{
if (Instance != this)
Destroy(Instance);

View File

@ -7,7 +7,6 @@ public class CameraSlotClickDetect : MonoBehaviour
{
public Camera mainCamera;
public LayerMask layerMask;
public LayerMask selectLayer;
private SlotManager PrevHoveredSlot;
@ -31,12 +30,6 @@ 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()

View File

@ -1,4 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -25,6 +24,7 @@ public class AimTower : Tower
public float HorizontalRotation => horizontalArc.Value;
public float VerticalRotation => verticalArc.Value;
protected override void Awake()
{
horizontalArc.Value.AddListener(UpdateBarrelRotation);
@ -35,18 +35,8 @@ 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()
@ -78,8 +68,6 @@ 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();
@ -96,6 +84,7 @@ public class AimTower : Tower
origin = hit.point;
}
trajectoryLine.positionCount = pointsInTrajectory.Count;
trajectoryLine.SetPositions(pointsInTrajectory.ToArray());

View File

@ -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);

View File

@ -1,10 +1,9 @@
using System;
using UnityEngine;
using UnityEngine.Assertions;
public abstract class Tower : MonoBehaviour
{
public Observer<bool> TowerSelected { get; set; } = new(false);
public bool towerSelected { get; set; } = true;
protected HealthComponent healthComp;
@ -14,20 +13,8 @@ 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()
{