Exemplo n.º 1
0
    public void CombatRaider()
    {
        RaiderDrone raiderDrone = DroneMgr.inst.GetClosestRaiderDrone(transform.position);

        if (raiderDrone != null)
        {
            ChangeState(UserDroneState.Combat);
            droneBase.addCommand(new PursueTargetToRadiusCommand(raiderDrone.GetDroneBase()));
            droneBase.addCommand(new ZeroVelocityCommand(droneBase));
        }
    }
Exemplo n.º 2
0
    public void RaiderDroneDestroyed(RaiderDrone destroyed)
    {
        raiderDrones.Remove(destroyed);

        DroneBase db = destroyed.GetComponent <DroneBase>();

        if (db != null)
        {
            allDrones.Remove(db);
        }

        if (raiderWarning && raiderDrones.Count <= 0)
        {
            raiderWarning = false;
            raiderAlarm.Stop();
        }
    }
Exemplo n.º 3
0
    public void RaiderDroneSpawned(RaiderDrone newDrone)
    {
        if (!raiderDrones.Contains(newDrone))
        {
            raiderDrones.Add(newDrone);

            DroneBase db = newDrone.GetComponent <DroneBase>();
            if (db != null)
            {
                allDrones.Add(db);
            }

            if (!raiderWarning)
            {
                raiderWarning = true;
                raiderAlarm.Play();
            }
        }
    }
Exemplo n.º 4
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.");
        }
    }
Exemplo n.º 5
0
    // Fixed Timestep
    void FixedUpdate()
    {
        if (type == DroneType.Hybrid || type == DroneType.Miner)
        {
            if (!droneBase.HasStorageAvailable() && state != UserDroneState.ReturnToBase)
            {
                ReturnToBase();
            }
        }

        if (type == DroneType.Hybrid || type == DroneType.Combat)
        {
            if (!droneBase.HasPower() && state != UserDroneState.ReturnToBase)
            {
                ReturnToBase();
            }
        }

        // Do damage to nearest drone in angle/range
        RaiderDrone raiderDrone = DroneMgr.inst.GetClosestRaiderDrone(transform.position);

        if ((type == DroneType.Hybrid || type == DroneType.Combat) && raiderDrone != null)
        {
            Vector3 positionDiff = raiderDrone.transform.position - droneBase.transform.position;
            if (positionDiff.magnitude <= 25.0f && Quaternion.Angle(Quaternion.LookRotation(positionDiff.normalized), transform.rotation) < 5.0)
            {
                raiderDrone.GetDroneBase().DoDamage(droneBase.DrawPower(droneBase.damage * (droneBase.GetDroneMaxStats().Power / 100)));
            }
        }

        if (state == UserDroneState.ReturnToBase)
        {
            // If its done returning to base and not docked...
            if (!isDocked && droneBase.isIdle())
            {
                this.gameObject.SetActive(false);
                isDocked = true;
                UnloadResources();
                droneBase.RefillPower();
                this.ChangeState(UserDroneState.Idle);
                droneCard.BeginAutoLaunch();
            }
        }

        if (state == UserDroneState.Idle)
        {
            // Combat tasking takes priority
            if (type == DroneType.Hybrid || type == DroneType.Combat)
            {
                CombatRaider();
            }

            // Mine asteroid
            if (type == DroneType.Hybrid || type == DroneType.Miner)
            {
                MineAsteroid();
            }
        }

        if (state == UserDroneState.Mining)
        {
            // Stop mining and attack raiders if they exist
            if (type == DroneType.Hybrid || type == DroneType.Combat)
            {
                CombatRaider();
            }

            // If idle, transition to idle state
            if (droneBase.isIdle())
            {
                ChangeState(UserDroneState.Idle);
            }
        }

        if (state == UserDroneState.Combat)
        {
            // If idle, transition to idle state
            if (droneBase.isIdle())
            {
                ChangeState(UserDroneState.Idle);
            }
        }
    }