Beispiel #1
0
 // Ensure that this remains Start to maintain correct ordering of script startup.
 internal void Start()
 {
     enemySighting      = GetComponent <EnemySighting>();
     lastPlayerSighting = enemySighting.LastSighting;
     drone = new Drone(MoveSpeed, RotationSpeed, this.gameObject, Waypoints, enemySighting, StoppingDistance, ChaseWaitTime, lastPlayerSighting, ShotsPerSecond, MuzzleFlash, Damage, DroneFireSound, ColorSet);
 }
Beispiel #2
0
        public Drone(float movementSpeed,
                     float rotationSpeed,
                     GameObject drone,
                     GameObject[] patrolRoute,
                     EnemySighting enemySighting,
                     float stoppingDistance,
                     float chaseWaitTime,
                     LastPlayerSighting lastPlayerSighting,
                     float shootRate,
                     GameObject[] muzzleFlash,
                     float droneDamage,
                     GameObject droneFireSound,
                     Vector3[] colorSet)
            : base(movementSpeed,
                   rotationSpeed,
                   drone)
        {
            index                   = 0;
            chaseTimer              = 0.0f;
            this.drone              = drone;
            this.patrolRoute        = patrolRoute;
            this.movementSpeed      = movementSpeed;
            this.enemySighting      = enemySighting;
            this.stoppingDistance   = stoppingDistance;
            this.chaseWaitTime      = chaseWaitTime;
            this.lastPlayerSighting = lastPlayerSighting;
            inverseLayer            = ~(1 << LayerMask.NameToLayer("Drone") | 1 << LayerMask.NameToLayer("SniperCollider"));
            inverseShootLayer       = ~(1 << LayerMask.NameToLayer("Drone") | 1 << LayerMask.NameToLayer("SmokeBomb") | 1 << LayerMask.NameToLayer("SniperCollider"));
            Random.seed             = System.Environment.TickCount;
            trackTime               = 0.0f;
            GameObject playerOne = GameObject.FindGameObjectWithTag("PlayerOne");
            GameObject playerTwo = GameObject.FindGameObjectWithTag("PlayerTwo");

            playerOneMovement = playerOne.GetComponent <FirstPersonMovement>();
            if (playerTwo != null)
            {
                playerTwoMovement = playerTwo.GetComponent <FirstPersonMovement>();
            }
            droneAnimator    = drone.GetComponent <Animator>();
            this.muzzleFlash = muzzleFlash;
            PlayerHealth playerOneHealth = playerOne.GetComponent <PlayerHealth>();

            PlayerHealth playerTwoHealth = null;

            if (playerTwo != null)
            {
                playerTwoHealth = playerTwo.GetComponent <PlayerHealth>();
            }
            hitFlash         = GameObject.FindGameObjectWithTag("GameManager").GetComponent <HitFlash>();
            this.droneWeapon = new DroneWeapon(droneDamage, 1.0f / shootRate, playerOneHealth, playerTwoHealth, droneFireSound, hitFlash, muzzleFlash, droneAnimator);
            foreach (Transform t in drone.transform)
            {
                if (t.tag == "DroneLight")
                {
                    Vector3 rgb         = colorSet[ColorIndex(shootRate, droneDamage)];
                    Color   threatColor = new Color(rgb[0] / 255f, rgb[1] / 255f, rgb[2] / 255f, 1);
                    t.gameObject.light.color = threatColor;
                    break;
                }
            }
        }