// Fixed timestep void FixedUpdate() { UserDrone userDrone = DroneMgr.inst.GetClosestUserDrone(transform.position); if (isEngagingUserDrone && droneBase.isIdle()) { isEngagingUserDrone = false; } if (userDrone != null) { Vector3 positionDiff = userDrone.transform.position - droneBase.transform.position; if (positionDiff.magnitude <= 25.0f && Quaternion.Angle(Quaternion.LookRotation(positionDiff.normalized), transform.rotation) < 5.0) { userDrone.GetDroneBase().DoDamage(droneBase.damage); } } if (!isEngagingUserDrone && userDrone != null) { isEngagingUserDrone = true; droneBase.ClearCommands(); droneBase.addCommand(new PursueTargetToRadiusCommand(userDrone.GetDroneBase())); } else if (droneBase.isIdle()) { droneBase.addCommand(new ZeroVelocityCommand(droneBase)); /// TODO: target Base/user } }
public void SetDroneOwner(DroneBase drone, OWNERS owner) { Color droneColor = Color.yellow; switch (owner) { case OWNERS.PLAYER: droneColor = Color.green; break; case OWNERS.RAIDER: droneColor = Color.red; break; case OWNERS.NEUTRAL: droneColor = Color.white; break; } foreach (Image image in images) { image.color = droneColor; } idText.color = droneColor; UserDrone uDrone = drone.GetComponent <UserDrone>(); if (uDrone != null) { idText.text = uDrone.GetStringIdentifier(); } }
public void DroneDestroyed(UserDrone drone) { cards.Remove(drone.droneCard); if (drone.droneCard != null) { Destroy(drone.droneCard.gameObject); } }
internal void SetDrone(UserDrone drone) { this.drone = drone; droneID.text = drone.GetStringIdentifier(); //barWidth = 340; }
private void BuildNewCard(UserDrone drone) { DroneCard droneCard = Instantiate(DroneCardPrefab).GetComponent <DroneCard>(); droneCard.transform.SetParent(panelParent); droneCard.transform.localPosition = Vector3.zero; droneCard.transform.localScale = Vector3.one; droneCard.transform.localEulerAngles = Vector3.zero; droneCard.SetDrone(drone); drone.droneCard = droneCard; cards.Add(droneCard); }
public void UserDroneSpawned(UserDrone newDrone) { if (!userDrones.Contains(newDrone)) { userDrones.Add(newDrone); droneList.DroneSpawned(newDrone); DroneBase db = newDrone.GetComponent <DroneBase>(); if (db != null) { allDrones.Add(db); } if (offeringEscape) { offeringEscape = false; quickEscape.gameObject.SetActive(false); } } }
/// Try to mine this asteroid public void Mine(float power, DroneBase drone, UserDrone uDrone) { if (uDrone == null) { return; } if (Resources.Iron > 0.0f || Resources.Copper > 0.0f || Resources.Uranium > 0.0f || Resources.Copper > 0.0f) { float ironMined = Mathf.Clamp(power * resourceRatios.Iron, 0.0f, Resources.Iron); float copperMined = Mathf.Clamp(power * resourceRatios.Copper, 0.0f, Resources.Copper); float uraniumMined = Mathf.Clamp(power * resourceRatios.Uranium, 0.0f, Resources.Uranium); float iceMined = Mathf.Clamp(power * resourceRatios.Ice, 0.0f, Resources.Ice); // TODO: The player currently gains some extra resources from each "mine" op // since the iron levels in an asteroid can go below zero. Fix this. /*GameMgr.inst.Resources.Iron += ironMined; * GameMgr.inst.Resources.Copper += copperMined; * GameMgr.inst.Resources.Uranium += uraniumMined; * GameMgr.inst.Resources.Ice += iceMined;*/ uDrone.minedResources.Iron += ironMined; uDrone.minedResources.Copper += copperMined; uDrone.minedResources.Uranium += uraniumMined; uDrone.minedResources.Ice += iceMined; drone.AddResourcesStored(ironMined + copperMined + uraniumMined + iceMined); Resources.Iron -= ironMined; Resources.Copper -= copperMined; Resources.Uranium -= uraniumMined; Resources.Ice -= iceMined; } if (IsEmpty()) { AsteroidMgr.inst.AsteroidDestroyed(this); gameObject.GetComponent <Fracture>().FractureObject(); } }
public void UserDroneDestroyed(UserDrone destroyed) { if (userDrones.Contains(destroyed)) { userDrones.Remove(destroyed); droneList.DroneDestroyed(destroyed); DroneBase db = destroyed.GetComponent <DroneBase>(); if (db != null) { allDrones.Remove(db); } if (userDrones.Count <= 0) { if (quickEscape != null) { quickEscape.gameObject.SetActive(true); } offeringEscape = true; } } }
public void DroneDestroyed(DroneBase drone) { UserDrone userDrone = drone.GetComponent <UserDrone>(); RaiderDrone raiderDrone = drone.GetComponent <RaiderDrone>(); if (userDrone != null && raiderDrone != null) { Debug.LogWarning("A drone was destroyed with both a UserDrone and RaiderDrone script."); } if (userDrone != null) { UserDroneDestroyed(userDrone); } else if (raiderDrone != null) { RaiderDroneDestroyed(raiderDrone); } else { Debug.LogWarning("A drone was destroyed without a UserDrone and RaiderDrone script."); } }
public MineAsteroidCommand(Asteroid target, UserDrone uDrone) { this.target = target; this.uDrone = uDrone; }
public void DroneSpawned(UserDrone drone) { BuildNewCard(drone); }
private void OnDisable() { this.drone = null; }