Пример #1
0
        public void RemoteUpdate(Fraction frac, float hp, byte boost, float charge, float shield, float sendertime)
        {
            if (frac != Fraction)
            {
                SetFraction(frac);
            }

            ManualBoost  = boost;
            BarrelCharge = charge;

            var delta = GDOwner.LevelTime - sendertime;

            CannonHealth.Set(hp);
            ShieldTime = shield;

            var ups = delta / (1 / 30f);

            if (ups > 1)
            {
                var iups = FloatMath.Min(FloatMath.Round(ups), 10);
                var gt30 = new SAMTime((delta / iups) * GDOwner.GameSpeed, MonoSAMGame.CurrentTime.TotalElapsedSeconds);

                for (int i = 0; i < iups; i++)
                {
                    RemoteUpdateSim(gt30);
                }
            }
        }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     playerHealth = player.GetComponent <CannonHealth> ();
     enemyHealth  = GetComponent <EnemyHealth>();
     _animator    = GetComponent <Animator> ();
 }
Пример #3
0
        private void RemoteUpdateSim(SAMTime gameTime)
        {
            CannonHealth.Update(gameTime);

            if (CannonHealth.TargetValue < 1 && CannonHealth.TargetValue > MIN_REGEN_HEALTH && (LastAttackingLasersEnemy <= LastAttackingLasersFriends))
            {
                var bonus = START_HEALTH_REGEN + (END_HEALTH_REGEN - START_HEALTH_REGEN) * CannonHealth.TargetValue;

                bonus /= Scale;

                CannonHealth.Inc(bonus * gameTime.ElapsedSeconds);
                CannonHealth.Limit(0f, 1f);
            }

            if (LastAttackingShieldLaser > 0)
            {
                ShieldTime += (SHIELD_CHARGE_SPEED)*gameTime.ElapsedSeconds;
                if (ShieldTime > MAX_SHIELD_TIME)
                {
                    ShieldTime = MAX_SHIELD_TIME;
                }
            }
            else
            {
                ShieldTime -= (SHIELD_DISCHARGE_SPEED)*gameTime.ElapsedSeconds;
                if (ShieldTime < 0)
                {
                    ShieldTime = 0;
                }
            }
        }
Пример #4
0
    void Start()
    {
        if (transform.position.x > 0)
        {
            particleRotation = -90;
        }

        cannonPipe  = transform.Find("CannonPipe");
        normalScale = transform.localScale;

        loadImage   = transform.Find("LoadImage").GetComponent <SpriteRenderer>();
        chargeSpeed = maxCharge / timeToFullCharge;

        SetAnglePoints();

        chargeIsntStarted = true;

        UpdateLoadImage(inventory.selectedBlock);

        animator = GetComponent <Animator>();

        cannonHealth = GetComponent <CannonHealth>();

        //Test : Roberts Test
        aim = GetComponent <AimCannon>();
    }
Пример #5
0
        public override void TakeLaserDamage(Fraction source, LaserRay ray, float dmg)
        {
            if (dmg > 0f)
            {
                if (Fraction.IsNeutral && !source.IsNeutral)
                {
                    CannonHealth.Set(1);
                    SetFraction(source);
                }
                else if (!Fraction.IsNeutral && source != Fraction)
                {
                    CannonHealth.Set(0);
                    SetFraction(Fraction.GetNeutral());
                }
            }

            if (!source.IsNeutral && !Fraction.IsNeutral)
            {
                if (dmg > 0)
                {
                    counterAttackingLasersEnemy++;
                }
                _attackingRaysCollector.Add(ray);
            }
        }
Пример #6
0
        public override void TakeDamage(Fraction source, float sourceScale)
        {
#if DEBUG
            if (DebugSettings.Get("ImmortalCannons"))
            {
                return;
            }
#endif

            if (Fraction.IsNeutral && !source.IsNeutral)
            {
                CannonHealth.Set(1);
                SetFraction(source);
            }
            else if (!Fraction.IsNeutral && source != Fraction)
            {
                if (counterAttackingLasersFriends > 0)
                {
                    // ignore
                }
                else
                {
                    CannonHealth.Set(0);
                    SetFraction(Fraction.GetNeutral());
                }
            }
        }
Пример #7
0
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag("Player").transform;
     nav          = GetComponent <UnityEngine.AI.NavMeshAgent> ();
     enemyHealth  = GetComponent <EnemyHealth> ();
     _animator    = GetComponent <Animator> ();
     playerHealth = player.GetComponent <CannonHealth> ();
 }
Пример #8
0
        protected override void OnUpdate(SAMTime gameTime, InputState istate)
        {
            controller.Update(gameTime, istate);

            bool change = Rotation.CUpdate(gameTime);

            if (change)
            {
                _screen.LaserNetwork.SemiDirty = true; ChargeTime = 0;
            }

            CrosshairSize.Update(gameTime);

            UpdatePhysicBodies();
            UpdateHealth(gameTime);
            UpdateBoost(gameTime);
            UpdateNetwork(gameTime);
            UpdateCore(gameTime);
            UpdateDamage(gameTime);
            UpdateShield(gameTime);

#if DEBUG
            if (IsMouseDownOnThis(istate) && DebugSettings.Get("AssimilateCannon"))
            {
                var bckp = DebugSettings.Get("ImmortalCannons");
                DebugSettings.SetManual("ImmortalCannons", false);

                while (Fraction.Type != FractionType.PlayerFraction)
                {
                    TakeDamage(this.GDOwner().GetPlayerFraction(), 1);
                }

                DebugSettings.SetManual("ImmortalCannons", bckp);

                CannonHealth.SetForce(1f);
            }
            if (IsMouseDownOnThis(istate) && DebugSettings.Get("LooseCannon"))
            {
                var bckp = DebugSettings.Get("ImmortalCannons");
                DebugSettings.SetManual("ImmortalCannons", false);

                while (Fraction.Type != FractionType.ComputerFraction)
                {
                    TakeDamage(this.GDOwner().GetComputerFraction(), 1);
                }

                DebugSettings.SetManual("ImmortalCannons", bckp);

                CannonHealth.SetForce(1f);
            }
            if (IsMouseDownOnThis(istate) && DebugSettings.Get("AbandonCannon"))
            {
                CannonHealth.SetForce(0f);
                SetFraction(Fraction.GetNeutral());
            }
#endif
        }
Пример #9
0
 void Awake()
 {
     player        = GameObject.FindGameObjectWithTag("Player").transform;
     nav           = GetComponent <UnityEngine.AI.NavMeshAgent> ();
     playerHealth  = player.GetComponent <CannonHealth> ();
     laserShotLine = GetComponentInChildren <LineRenderer> ();
     currentHealth = startingHealth;
     audioSource   = gameObject.GetComponent <AudioSource> ();
 }
Пример #10
0
    void Awake()
    {
        player        = GameObject.FindGameObjectWithTag("Player").transform;
        nav           = GetComponent <UnityEngine.AI.NavMeshAgent> ();
        enemyHealth   = GetComponent <EnemyHealth> ();
        _animator     = GetComponent <Animator> ();
        playerHealth  = player.GetComponent <CannonHealth> ();
        laserShotLine = GetComponentInChildren <LineRenderer> ();
        audioSource   = GetComponent <AudioSource> ();

        laserShotLine.enabled = false;
    }
Пример #11
0
        public override void ApplyBoost()
        {
            if (Fraction.IsNeutral)
            {
                return;
            }

            CannonHealth.Inc(HEALTH_HIT_GEN);
            if (CannonHealth.Limit(0f, 1f) == 1)
            {
                AddEntityOperation(new CannonBooster(1 / (BOOSTER_LIFETIME_MULTIPLIER * Fraction.BulletMultiplicator)));
            }
        }
Пример #12
0
        private void RemoteUpdateSim(SAMTime gameTime)
        {
            CannonHealth.Update(gameTime);

            if (CannonHealth.TargetValue < 1 && CannonHealth.TargetValue > MIN_REGEN_HEALTH && (LastAttackingLasersEnemy <= LastAttackingLasersFriends))
            {
                var bonus = START_HEALTH_REGEN + (END_HEALTH_REGEN - START_HEALTH_REGEN) * CannonHealth.TargetValue;

                bonus /= Scale;

                CannonHealth.Inc(bonus * gameTime.ElapsedSeconds);
                CannonHealth.Limit(0f, 1f);
            }

            if ((CannonHealth.TargetValue >= 1 || Fraction.IsNeutral))
            {
                float chargeDelta = BARREL_CHARGE_SPEED_TRISHOT * Fraction.BulletMultiplicator * RealBoost * gameTime.ElapsedSeconds;
                if (Scale > 2.5f)
                {
                    chargeDelta /= Scale;
                }

                BarrelCharge += chargeDelta;

                if (BarrelCharge >= 1f)
                {
                    BarrelCharge -= 1f;

                    barrelRecoil = 0f;
                }
            }

            if (LastAttackingShieldLaser > 0)
            {
                ShieldTime += (SHIELD_CHARGE_SPEED)*gameTime.ElapsedSeconds;
                if (ShieldTime > MAX_SHIELD_TIME)
                {
                    ShieldTime = MAX_SHIELD_TIME;
                }
            }
            else
            {
                ShieldTime -= (SHIELD_DISCHARGE_SPEED)*gameTime.ElapsedSeconds;
                if (ShieldTime < 0)
                {
                    ShieldTime = 0;
                }
            }
        }
Пример #13
0
        private void UpdateCore(SAMTime gameTime)
        {
            if (CannonHealth.ActualValue < FULL_LASER_HEALTH || Fraction.IsNeutral)
            {
                CorePulse.Set(1);
            }
            else
            {
                CorePulse.Set(1 + FloatMath.Sin(gameTime.TotalElapsedSeconds * CORE_PULSE_FREQ) * CORE_PULSE);
            }
            CorePulse.Update(gameTime);

            if (CannonHealth.ActualValue < FULL_LASER_HEALTH || Fraction.IsNeutral || !LaserSource.LaserPowered)
            {
                if (LaserPulseTime > 0f)
                {
                    LaserPulseTime = FloatMath.LimitedDec(LaserPulseTime, gameTime.ElapsedSeconds, 0f);
                }
            }
            else
            {
                LaserPulseTime += gameTime.ElapsedSeconds;
            }

            ChargeTime += gameTime.ElapsedSeconds;

            if (CannonHealth.ActualValue < 1)
            {
                ChargeTime = 0;
            }

            if (CannonHealth.ActualValue < 1)
            {
                SatelliteExpansion.Set(0);
            }
            else
            {
                SatelliteExpansion.Set(1);
            }

            SatelliteExpansion.Update(gameTime);

            if (SatelliteExpansion.ActualValue > 0)
            {
                CannonHealth.SetActual(1);
            }

            _coreRotation += gameTime.ElapsedSeconds * FloatMath.TAU * SHIELD_SATELLITE_SPEED;
        }
Пример #14
0
        public void RemoteUpdate(Fraction frac, float hp, byte boost, float chrg, float sendertime)
        {
            if (frac != Fraction)
            {
                SetFraction(frac);
            }

            ManualBoost = boost;

            var delta = GDOwner.LevelTime - sendertime;

            ChargeTime = chrg + delta;

            CannonHealth.Set(hp);

            var ups = delta / (1 / 30f);

            if (ups > 1)
            {
                var iups = FloatMath.Min(FloatMath.Round(ups), 10);
                var gt30 = new SAMTime((delta / iups) * GDOwner.GameSpeed, MonoSAMGame.CurrentTime.TotalElapsedSeconds);

                for (int i = 0; i < iups; i++)
                {
                    CannonHealth.Update(gt30);

                    if (CannonHealth.TargetValue < 1 && CannonHealth.TargetValue > MIN_REGEN_HEALTH && (LastAttackingLasersEnemy <= LastAttackingLasersFriends))
                    {
                        var bonus = START_HEALTH_REGEN + (END_HEALTH_REGEN - START_HEALTH_REGEN) * CannonHealth.TargetValue;

                        bonus /= Scale;

                        CannonHealth.Inc(bonus * gt30.ElapsedSeconds);
                        CannonHealth.Limit(0f, 1f);
                    }
                }
            }
        }
Пример #15
0
        public override void ApplyLaserBoost(LaserCannon src, float pwr)
        {
            if (Fraction.IsNeutral)
            {
                return;
            }

            if (pwr > 0)
            {
                counterAttackingLasersFriends++;

                if (Fraction.IsNeutral && !src.Fraction.IsNeutral)
                {
                    CannonHealth.Set(1);
                    SetFraction(src.Fraction);
                }
                else if (!Fraction.IsNeutral && src.Fraction != Fraction)
                {
                    CannonHealth.Set(0);
                    SetFraction(Fraction.GetNeutral());
                }
            }
        }
Пример #16
0
 public override void SetFractionAndHealth(Fraction fraction, float hp)
 {
     SetFraction(fraction);
     CannonHealth.Set(hp);
     CannonHealth.Limit(0f, 1f);
 }
Пример #17
0
        private void RemoteUpdateSim(SAMTime gameTime)
        {
            CannonHealth.Update(gameTime);

            if (CannonHealth.TargetValue < 1 && CannonHealth.TargetValue > MIN_REGEN_HEALTH && (LastAttackingLasersEnemy <= LastAttackingLasersFriends))
            {
                var bonus = START_HEALTH_REGEN + (END_HEALTH_REGEN - START_HEALTH_REGEN) * CannonHealth.TargetValue;

                bonus /= Scale;

                CannonHealth.Inc(bonus * gameTime.ElapsedSeconds);
                CannonHealth.Limit(0f, 1f);
            }

            if (CannonHealth.TargetValue >= 1)
            {
                float chargeDelta = BARREL_CHARGE_SPEED_MINIGUN * Fraction.BulletMultiplicator * RealBoost * gameTime.ElapsedSeconds;
                if (Scale > 2.5f)
                {
                    chargeDelta /= Scale;
                }

                if (_remainingBullets > 0)
                {
                    _nextBulletTime -= gameTime.ElapsedSeconds;

                    if (_nextBulletTime <= 0)
                    {
                        barrelRecoil = 0f;

                        _remainingBullets--;
                        _nextBulletTime += MINIGUN_BULLET_DELAY;
                    }

                    if (_remainingBullets <= 0)
                    {
                        _nextBulletTime = 0;
                    }
                }
                else
                {
                    BarrelCharge += chargeDelta;

                    if (BarrelCharge >= 1f)
                    {
                        BarrelCharge -= 1f;

                        _remainingBullets = MINIGUN_BULLET_COUNT;
                    }
                }
            }

            if (LastAttackingShieldLaser > 0)
            {
                ShieldTime += (SHIELD_CHARGE_SPEED)*gameTime.ElapsedSeconds;
                if (ShieldTime > MAX_SHIELD_TIME)
                {
                    ShieldTime = MAX_SHIELD_TIME;
                }
            }
            else
            {
                ShieldTime -= (SHIELD_DISCHARGE_SPEED)*gameTime.ElapsedSeconds;
                if (ShieldTime < 0)
                {
                    ShieldTime = 0;
                }
            }
        }
Пример #18
0
 public override void SetFractionAndHealth(Fraction fraction, float hp)
 {
     SetFraction(fraction);
     CannonHealth.Set(1);
 }
Пример #19
0
 // Use this for initialization
 void Start()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     FireAudio    = GetComponent <AudioSource> ();
     playerHealth = player.GetComponent <CannonHealth> ();
 }