Esempio n. 1
0
    // 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
        }
    }
Esempio n. 2
0
    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();
        }
    }
Esempio n. 3
0
 public void DroneDestroyed(UserDrone drone)
 {
     cards.Remove(drone.droneCard);
     if (drone.droneCard != null)
     {
         Destroy(drone.droneCard.gameObject);
     }
 }
Esempio n. 4
0
    internal void SetDrone(UserDrone drone)
    {
        this.drone = drone;

        droneID.text = drone.GetStringIdentifier();

        //barWidth = 340;
    }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
    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);
            }
        }
    }
Esempio n. 7
0
    /// 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();
        }
    }
Esempio n. 8
0
    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;
            }
        }
    }
Esempio n. 9
0
    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.");
        }
    }
Esempio n. 10
0
 public MineAsteroidCommand(Asteroid target, UserDrone uDrone)
 {
     this.target = target;
     this.uDrone = uDrone;
 }
Esempio n. 11
0
 public void DroneSpawned(UserDrone drone)
 {
     BuildNewCard(drone);
 }
Esempio n. 12
0
 private void OnDisable()
 {
     this.drone = null;
 }