Beispiel #1
0
    void CreateMissile(MissileEntity missileEntity)
    {
        Vector3 missilePosition = new Vector3
        {
            x = missileEntity.location.x,
            y = missileEntity.location.y,
            z = missileEntity.location.z
        };

        Quaternion missileRotation = Quaternion.Euler(
            missileEntity.rotation.x,
            missileEntity.rotation.y,
            missileEntity.rotation.z
            );

        int eneityID = missileEntity.entityID;

        GameObject newMissile = null;

        if (missileEntity.playerID == GameSettings.playerID)
        {
            newMissile = Instantiate(Missile, missilePosition, missileRotation);
            newMissile.transform.Rotate(GameSettings.MISSILE_LOCAL_ROTATE);

            MissileControl missileControl = newMissile.GetComponent <MissileControl>();
            missileControl.missileID = missileEntity.entityID;
            missileControl.playerID  = missileEntity.playerID;
        }
        // is missile is from other clients, then disable the trigger
        else
        {
            newMissile = Instantiate(Missile, missilePosition, missileRotation);

            CapsuleCollider capsuleCollider = newMissile.GetComponent <CapsuleCollider>();
            capsuleCollider.enabled = false;

            newMissile.transform.Rotate(GameSettings.MISSILE_LOCAL_ROTATE);

            MissileControl missileControl = newMissile.GetComponent <MissileControl>();
            missileControl.missileID = missileEntity.entityID;
            missileControl.playerID  = missileEntity.playerID;
        }

        AddServerGameObjects(GameSettings.MISSILE_TYPE, eneityID, newMissile);
    }
        public override void Update()
        {
            base.Update();

            if (_isDying)
            {
                if (_dyingCountDown <= 0)
                {
                    Core.InvasionScene.KillInvader(this);
                    Core.PlayerScore += Points;
                }
                else
                {
                    _dyingCountDown--;
                }
            }
            else if (Rand.Chance(FireChance) && !Core.InvasionScene.Hero.IsDying)
            {
                _fireSound.Play();
                var missile = new MissileEntity(X, Y, BulletDirection.Down);
                Core.InvasionScene.AddAlienMissile(missile);
            }
        }
#pragma warning disable 8618
        public MissileLauncher(MissileEntity missileFactory)
#pragma warning restore 8618
        {
            _missileFactory = missileFactory;
        }