Esempio n. 1
0
        public AmmunitionObsoleteSerializable Serialize()
        {
            var serializable = new AmmunitionObsoleteSerializable();

            serializable.Id                  = ItemId.Id;
            serializable.FileName            = ItemId.Name;
            serializable.ItemType            = (int)ItemType.AmmunitionObsolete;
            serializable.AmmunitionClass     = AmmunitionClass;
            serializable.DamageType          = DamageType;
            serializable.Impulse             = Impulse.Value;
            serializable.Recoil              = Recoil.Value;
            serializable.Size                = Size.Value;
            serializable.InitialPosition     = InitialPosition;
            serializable.AreaOfEffect        = AreaOfEffect.Value;
            serializable.Damage              = Damage.Value;
            serializable.Range               = Range.Value;
            serializable.Velocity            = Velocity.Value;
            serializable.LifeTime            = LifeTime.Value;
            serializable.HitPoints           = HitPoints.Value;
            serializable.IgnoresShipVelocity = IgnoresShipVelocity;
            serializable.EnergyCost          = EnergyCost.Value;
            serializable.CoupledAmmunitionId = CoupledAmmunitionId.Id;
            serializable.Color               = Utils.ColorUtils.ColorToString(Color);
            serializable.FireSound           = FireSound.ToString();
            serializable.HitEffectPrefab     = HitEffectPrefab;
            serializable.BulletPrefab        = BulletPrefab;
            return(serializable);
        }
Esempio n. 2
0
    private void AIShoot()
    {
        if (FireSound != null)
        {
            FireSound.Play();
        }

        Vector3 point = gameObject.transform.forward;

        Vector3 StartingPoint;

        if (ShootingZone != null)
        {
            StartingPoint = ShootingZone.transform.position;
        }
        else
        {
            StartingPoint = gameObject.transform.position;
        }

        CmdShoot(point, StartingPoint);
    }
Esempio n. 3
0
 public void Update(GameTime time)
 {
     if (KeyboardHelper.KeyPressed(Keys.Escape))
     {
         paused = !paused;
         if (paused)
         {
             return;
         }
     }
     heatMap.UpdateBegin(time);
     winTimer.Update(time);
     fireSndTimer.Update(time);
     fireExtSndTimer.Update(time);
     if (winTimer.HasTick())
     {
         if (game.LevelSelectScreen.Progress < levelId)
         {
             game.LevelSelectScreen.Progress = levelId;
         }
         game.ChangeScreen(game.LevelEndScreen.SetWin(true));
     }
     else if (gameObjectInstances.Where(inst => !inst.IsDestroyed).Sum(inst => inst.Type.Cost) < startingCost / 3 || player.IsDead)
     {
         game.ChangeScreen(game.LevelEndScreen.SetWin(false));
     }
     foreach (var inst in gameObjectInstances)
     {
         inst.Update(time, heatMap, partSystem, this);
     }
     foreach (var inst in gameObjectInstances)
     {
         inst.UpdateFromHeatmap(heatMap);
     }
     partSystem.Update(time);
     foreach (var agent in partSystem.GetAgents())
     {
         var c = agent.CollisionMask;
         foreach (var inst in gameObjectInstances)
         {
             if (inst.IsBurning && inst.CollidesWith(c))
             {
                 inst.Extinguish(agent.Type);
             }
         }
         heatMap.CoolDown(new Point(c.X, c.Y));
         if (wallColliders.Any(w => w.CollidesWith(c)))
         {
             agent.Kill();
         }
     }
     player.Update(time, heatMap, partSystem);
     if (gameObjectInstances.Any(inst => inst.IsBurning))
     {
         winTimer.Reset();
     }
     if (fireSndTimer.HasTick())
     {
         var b = Math.Min(2000f, gameObjectInstances.Sum(inst => inst.Burning));
         if (b > 0)
         {
             FireSound.Play(b / 2000f, 0f, 0f);
         }
     }
     fireSndTimer.TakeTicks();
     fireExtSndTimer.TakeTicks();
 }
    public void DelegateFireAndReload()
    {
        // Clear delegates
        primaryFire = null;
        secondaryFire = null;
        secondaryReload = null;
        primaryFireSound = null;
        secondaryFireSound = null;

        // Loop through children
        foreach(Transform child in transform)
        {
            // Get child's WeaponControl script
            tempScript = child.GetComponent<WeaponControl>();

            // Check if child has a WeaponControl script
            if(tempScript!=null)
            {
                // Check if child is a Primary Weapon
                if(tempScript.weaponType==1)
                {
                    // Store FireCall() in a delegate
                    primaryFire += tempScript.FireCall;

                    int ii = 0;
                    bool matched = false;
                    while(ii<child.GetSiblingIndex())
                    {
                        if(transform.GetChild(ii).name == child.name)
                        {
                            matched = true;
                        }
                        ii++;
                    }
                    if(!matched)
                    {
                        primaryFireSound += tempScript.FiringSoundCall;
                    }
                }
                // Check if child is a Secondary Weapon
                else if(tempScript.weaponType==2)
                {
                    // Store FireCall() in a delegate
                    secondaryFire += tempScript.FireCall;

                    int ii = 0;
                    bool matched = false;
                    while(ii<child.GetSiblingIndex())
                    {
                        if(transform.GetChild(ii).name == child.name)
                        {
                            matched = true;
                        }
                        ii++;
                    }
                    if(!matched)
                    {
                        secondaryFireSound += tempScript.FiringSoundCall;
                    }

                    // Store ReloadCall() in a delegate
                    secondaryReload += tempScript.ReloadCall;
                }
            }
        }
    }