Example #1
0
        /// <summary>
        /// Does nothing if object is dead
        /// </summary>
        /// <param name="hitObject"></param>
        /// <param name="firingObject"></param>
        /// <param name="projectileType"></param>
        /// <param name="pctCharge"></param>
        /// <param name="weaponSlot"></param>
        /// <param name="projectileID"></param>
        void DamageObject(ICollidable hitObject, ICanFire firingObject, ProjectileTypes projectileType, byte pctCharge, byte weaponSlot, int projectileID)
        {
            hitObject.TimeOfLastCollision = TimeKeeper.MsSinceInitialization;
            float multiplier = 1;

            if (firingObject is IShip)
            {
                multiplier = ((IShip)firingObject).StatBonuses[StatBonusTypes.Damage] / (1 + ((IShip)firingObject).Debuffs[DebuffTypes.Damage]);
            }

            Weapon firingWeapon = firingObject.GetWeapon(weaponSlot);
            Dictionary <DebuffTypes, int> debuffsAdded = null;

            if (firingWeapon != null && firingWeapon.DebuffType != DebuffTypes.None)
            {
                debuffsAdded = new Dictionary <DebuffTypes, int>();
                debuffsAdded.Add(firingWeapon.DebuffType, firingWeapon.DebuffCount);
                hitObject.Debuffs.AddDebuff(firingWeapon.DebuffType, firingWeapon.DebuffCount, TimeKeeper.MsSinceInitialization);
            }

            //WARNING: Concurrent processing may cause this to take damage more than once for the same collision
            bool isDead = hitObject.TakeDamage(projectileType, pctCharge, multiplier);

            if (isDead && hitObject is IKillable)
            {
                _killManager.Kill((IKillable)hitObject, firingObject);
            }
            else
            {
                if (hitObject is IShip)
                {
                    _messageManager.SendShipDamage((IShip)hitObject, debuffsAdded);
                }
            }
        }
Example #2
0
    void ChangeProjectile(ProjectileTypes pt)
    {
        projectileType = pt;
        switch (projectileType)
        {
        case ProjectileTypes.Tomato:
            break;

        case ProjectileTypes.Corn:
            break;

        case ProjectileTypes.Carrot:
            break;
            //case ProjectileTypes.Potato:
            //	break;
            //case ProjectileTypes.Cabbage:
            //	break;
            //case ProjectileTypes.Cucumber:
            //	break;
            //case ProjectileTypes.Zucchini:
            //	break;
            //case ProjectileTypes.Onion:
            //	break;
            //case ProjectileTypes.Spinach:
            //	break;
            //case ProjectileTypes.Parsnip:
            //	break;
        }
    }
Example #3
0
        private void UpdateIndicatorDisplay(CharacterHandler player, GameObject rockInd,
                                            GameObject paperInd, GameObject scissorsInd, Image selectedProjectile)
        {
            ProjectileTypes pType = player.sB.GetSelectedWeapon();

            switch (pType)
            {
            case ProjectileTypes.ROCK:
                rockInd.SetActive(true);
                paperInd.SetActive(false);
                scissorsInd.SetActive(false);
                selectedProjectile.sprite = rock;
                break;

            case ProjectileTypes.PAPER:
                rockInd.SetActive(false);
                paperInd.SetActive(true);
                scissorsInd.SetActive(false);
                selectedProjectile.sprite = paper;
                break;

            case ProjectileTypes.SCISSORS:
                rockInd.SetActive(false);
                paperInd.SetActive(false);
                scissorsInd.SetActive(true);
                selectedProjectile.sprite = scissors;
                break;

            default:
                break;
            }
        }
        public Projectile(Coordinates coordinates, ProjectileTypes type, long initialTime)
        {
            _myInitialCoordinates = coordinates;
            _currCoordinates      = coordinates;
            _prevCoordinates      = coordinates;
            _myInitialTime        = initialTime;
            MyType = type;

            switch (MyType)
            {
            case ProjectileTypes.EnemyProjectile:
                _mSecondsPerMove = 50;
                break;

            case ProjectileTypes.HeroProjectile:
                _mSecondsPerMove = -20;
                break
                ;

            case ProjectileTypes.LifeBonus:
                _mSecondsPerMove = 100;
                break;

            case ProjectileTypes.LevelUp:
                _mSecondsPerMove = 100;
                break;
            }
        }
    public static Projectile RequestProjectile(ProjectileTypes type)
    {
        if (!pools.ContainsKey(type))
        {
            return(null);
        }

        Pool       pool = pools[type];
        Projectile p    = null;

        if (pool.pooledProjectiles.Count > 0)
        {
            p = pool.pooledProjectiles.Dequeue();
        }
        else
        {
            if (NetworkServer.active)
            {
                p = GameObject.Instantiate(library.projectilePrefabs[type]).GetComponent <Projectile>();
                NetworkServer.Spawn(p.gameObject);
            }
            else
            {
                p = GameObject.Instantiate(library.projectilePrefabs[type]).GetComponent <Projectile>();
            }
        }

        p.Active = true;
        return(p);
    }
        /// <summary>
        /// Finds the first, if existand, bonus projectile that overlaps or is below the hero ship and does the appropriate action.
        /// </summary>
        /// <param name="bonusProjectiles">The list of all bonus projectiles on the board.</param>
        public void BonusProjectileHit(List <Projectile> bonusProjectiles)
        {
            ProjectileTypes projectileType = new ProjectileTypes();

            if (bonusProjectiles.ProjectileHitList(GetPosition(), GetRelativeBoundry(), out projectileType))
            {
                if (projectileType == ProjectileTypes.LevelUp)
                {
                    if (_rnd.Next(2) == 0)
                    {
                        LevelUp();
                    }
                    else
                    {
                        EngineLevelUp();
                    }
                }
                else
                {
                    HealthUp();
                }
            }

            ForceDisplay();
        }
Example #7
0
        private void UpdateAmmoDisplay(CharacterHandler player, TextMeshProUGUI currentAmmo, TextMeshProUGUI maxAmmo)
        {
            ProjectileTypes pType = player.sB.GetSelectedWeapon();

            if (pType == ProjectileTypes.ROCK)
            {
                (float maxRock, float currentRock) = player.sB.GetMana(ProjectileTypes.ROCK);

                currentAmmo.text = currentRock.ToString();
                maxAmmo.text     = "/" + maxRock.ToString();
            }

            else if (pType == ProjectileTypes.PAPER)
            {
                (float maxPaper, float currentPaper) = player.sB.GetMana(ProjectileTypes.PAPER);

                currentAmmo.text = currentPaper.ToString();
                maxAmmo.text     = "/" + maxPaper.ToString();
            }

            else
            {
                (float maxScissors, float currentScissors) = player.sB.GetMana(ProjectileTypes.SCISSORS);

                currentAmmo.text = currentScissors.ToString();
                maxAmmo.text     = "/" + maxScissors.ToString();
            }
        }
Example #8
0
 public void SetMissileType(ProjectileTypes missileType)
 {
     if (Stats.ProjectileType == missileType)
     {
         return;
     }
     Stats = new MissileLauncherStats(missileType);
 }
Example #9
0
    void ChooseRandomResource()
    {
        ProjectileTypes[] projectileTypes = Enum.GetValues(typeof(ProjectileTypes)) as ProjectileTypes[];

        ProjectileTypes pt = projectileTypes[UnityEngine.Random.Range(0, projectileTypes.Length)];

        resource.GetComponent <SpriteRenderer>().sprite = spritesDict[pt];
        ResourcesManager.instance.AddResource(pt);
    }
Example #10
0
 /// <summary>
 /// ProjectileIDs must be unique
 /// </summary>
 /// <param name="firingObject"></param>
 /// <param name="firingRotation">rotation of fired weapon</param>
 /// <param name="firingWeaponSlot"></param>
 /// <param name="pctCharge"></param>
 /// <param name="sendToServer"></param>
 /// <param name="projectileType"></param>
 public ProjectileRequest(ICanFire firingObject, float firingRotation, byte firingWeaponSlot, byte pctCharge, bool sendToServer, ProjectileTypes projectileType)
 {
     _projectileData  = new List <ProjectileData>();
     _projectileIDs   = new List <int>();
     FiringObj        = firingObject;
     SendToServer     = sendToServer;
     FiringWeaponSlot = firingWeaponSlot;
     PctCharge        = pctCharge;
     ProjectileType   = projectileType;
     FiringRotation   = firingRotation;
 }
Example #11
0
 public static MEDIA_ID GetProjectileMediaID(ProjectileTypes type)
 {
     switch(type)
     {
         case ProjectileTypes.Teacher:
             return MEDIA_ID.PROJECTILE_2;
         case ProjectileTypes.Gavel:
             return MEDIA_ID.PROJECTILE_0;
         default:
             return MEDIA_ID.PROJECTILE_1;
      }
 }
Example #12
0
        public Projectile(WeaponStats stats, Creep targetCreep, Vector2 startPoint, TowerTypes parentTowerType)
        {
            Stats = stats.GetCopy();
            TargetCreep = targetCreep;

            CenterPosition = startPoint;

            this.type = SelectTypeBasedOnTowerType(parentTowerType);
            this.TextureID =  TowerFactory.GetProjectileMediaID(type);

            this.numFrames = ProjectileDefinitions.ProjectileStats[type].NumFrames;
        }
Example #13
0
    public void UpdateAllResourceCounts()
    {
        Debug.Log("Update All Resource Counts");
        fruitTreeButton.GetComponentInChildren <Text>().text = ResourcesManager.instance.currentTrees.ToString();

        foreach (var button in projectileButtons)
        {
            ProjectileTypes projectileType = button.GetComponent <ResourceButton_Projectile>().projectileType;

            UpdateResourceCount(button.GetComponentInChildren <Text>(), ResourcesManager.instance.currentResourcesDict[projectileType]);
        }
    }
Example #14
0
        public Projectile(WeaponStats stats, Creep targetCreep, Vector2 startPoint, TowerTypes parentTowerType)
        {
            Stats       = stats.GetCopy();
            TargetCreep = targetCreep;

            CenterPosition = startPoint;

            this.type      = SelectTypeBasedOnTowerType(parentTowerType);
            this.TextureID = TowerFactory.GetProjectileMediaID(type);

            this.numFrames = ProjectileDefinitions.ProjectileStats[type].NumFrames;
        }
Example #15
0
    void Start()
    {
        fruitTreeButton.GetComponentInChildren <Text>().text = ResourcesManager.instance.currentTrees.ToString();

        foreach (GameObject button in projectileButtons)
        {
            ProjectileTypes projectileType = button.GetComponent <ResourceButton_Projectile>().projectileType;

            projectileButtonDict.Add(projectileType, button);
            button.GetComponentInChildren <Text>().text = ResourcesManager.instance.currentResourcesDict[projectileType].ToString();
        }
    }
Example #16
0
 public void AddResource(ProjectileTypes pt)
 {
     if (pt == ProjectileTypes.None)
     {
         currentTrees++;
     }
     else
     {
         currentResourcesDict[pt]++;
     }
     resourcePanel.UpdateAllResourceCounts();
 }
Example #17
0
            public Collision(int hitObjectID, int projectileID, ProjectileTypes projectileType, byte pctCharge, byte weaponSlot)
            {
                HitObjectID = hitObjectID;

                ProjectileID = projectileID;

                ProjectileType = projectileType;

                PctCharge = pctCharge;

                WeaponSlot = weaponSlot;
            }
Example #18
0
        public static MEDIA_ID GetProjectileMediaID(ProjectileTypes type)
        {
            switch (type)
            {
            case ProjectileTypes.Teacher:
                return(MEDIA_ID.PROJECTILE_2);

            case ProjectileTypes.Gavel:
                return(MEDIA_ID.PROJECTILE_0);

            default:
                return(MEDIA_ID.PROJECTILE_1);
            }
        }
Example #19
0
        public MissileLauncherStats(ProjectileTypes missileType)
        {
            Weight = 0;

            if (!Validation.IsMissileType(missileType))
            {
                throw new InvalidOperationException("Non missile type passed to MissileLauncherStats constructor");
            }

            MissileType    = (StatelessCargoTypes)Enum.Parse(typeof(StatelessCargoTypes), missileType.ToString());
            ProjectileType = missileType;
            NumProjectiles = 1;
            FirePeriod     = 100f;
            EnergyCost     = 100f;
            WeaponType     = WeaponTypes.MissileLauncher;
        }
Example #20
0
        public static bool IsMissileType(ProjectileTypes projectileType)
        {
            switch (projectileType)
            {
            case ProjectileTypes.AmbassadorMissile:
            case ProjectileTypes.HellHoundMissile:
            case ProjectileTypes.MissileType1:
            case ProjectileTypes.MissileType2:
            case ProjectileTypes.MissileType3:
            case ProjectileTypes.MissileType4:
                return(true);

            default:
                return(false);
            }
        }
        /// <summary> Retrieve a bullet from a pool. </summary>
        /// <param name="type"> The type of bullet to get. </param>
        /// <returns> The gameObject of the bullet or null if there are none available. </returns>
        public GameObject GetProjectile(ProjectileTypes type)
        {
            IPoolable entity = AllocateEntity(this.projectilePools[(int)type]);

            if (entity == null)
            {
                return(null);
            }

            if (type == ProjectileTypes.Enemy)
            {
                SoundPool.instance.PlaySound(SoundClips.instance.Laser2, entity.GetGameObject().transform.position, false, false, 0.25f);
            }
            else if (type == ProjectileTypes.Player)
            {
                SoundPool.instance.PlaySound(SoundClips.instance.PlayerLaser, transform.position, false, false, 0.1f);
            }
            return(entity.GetGameObject());
        }
Example #22
0
        // Constructor:
        public CProjectile(float x, float y, Directions d, ProjectileTypes type)
        {
            // Loading images:
            this.img_down = new List <Image> {
                Properties.Resources.projectile_down
            };

            this.img_up = new List <Image> {
                Properties.Resources.projectile_up
            };

            this.img_left = new List <Image> {
                Properties.Resources.projectile_left
            };

            this.img_right = new List <Image> {
                Properties.Resources.projectile_right
            };

            // Set size in tiles:
            this.Width = 8;

            this.Height = 8;

            // set coordinates:
            this.X = x + 12;

            this.Y = y + 12;

            // Set vector:
            this.Direction = d;

            // Alowing to move:
            this.AllowedToMove = true;

            this.ProjectileType = type;

            // Speed:
            this.Speed = type == ProjectileTypes.Slow ? 4 : 8;

            // Setting drawing priority:
            this.DrawPriority = 6;
        }
Example #23
0
        public static float DamageAmount(this IShip s, ProjectileTypes type, byte pctCharge)
        {
            //Calculate damage based on modules and whatever else WARNING: needs to be implemented properly
            switch (type)
            {
            case ProjectileTypes.Laser:
                return(500);

            case ProjectileTypes.BC_Laser:
                return(900);

            case ProjectileTypes.LaserWave:
                return(150);

            case ProjectileTypes.PlasmaCannon:
                return(2000 * pctCharge);

            case ProjectileTypes.AmbassadorMissile:
                return(20000 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.HellHoundMissile:
                return(30000 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType1:
                return(20000 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType2:
                return(20000 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType3:
                return(20000 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType4:
                return(20000 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MineSplash:
                return(900 * pctCharge);

            default:
                return(100);
            }
        }
Example #24
0
        private CollisionObject getColObject(int projectileID, ProjectileTypes projectileType, ICollidable hitObject, byte pctCharge, byte weaponSlot)
        {
            CollisionObject tempCol;

            if (!_preAllocatedCollisionObjects.TryPop(out tempCol))
            {
                for (int i = 0; i < 500; i++) //Every time the capacity is exceeded, create 500 more objects.
                {
                    _preAllocatedCollisionObjects.Push(new CollisionObject());
                }
                _preAllocatedCollisionObjects.TryPop(out tempCol);
            }
            tempCol.projectileID   = projectileID;
            tempCol.projectileType = projectileType;
            tempCol.hitObject      = hitObject;
            tempCol.reportTime     = TimeKeeper.MsSinceInitialization;
            tempCol.pctCharge      = pctCharge;
            tempCol.WeaponSlot     = weaponSlot;
            return(tempCol);
        }
Example #25
0
        public static float EnergyAmount(this IShip s, ProjectileTypes type, byte pctCharge)
        {
            switch (type)
            {
            case ProjectileTypes.Laser:
                return(50);

            case ProjectileTypes.BC_Laser:
                return(150);

            case ProjectileTypes.LaserWave:
                return(200);

            case ProjectileTypes.PlasmaCannon:
                return(500 * pctCharge);

            case ProjectileTypes.AmbassadorMissile:
                return(200 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.HellHoundMissile:
                return(300 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType1:
                return(200 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType2:
                return(200 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType3:
                return(200 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MissileType4:
                return(200 * pctCharge);     //Splash represented by pctCharge

            case ProjectileTypes.MineSplash:
                return(900 * pctCharge);

            default:
                return(50);
            }
        }
Example #26
0
        /// <summary>
        /// Instantiates a new instance of the given weapon type
        /// </summary>
        /// <param name="weaponType"></param>
        /// <param name="missileType">Used inly if weaponType is MissileLauncher</param>
        /// <returns></returns>
        static public Weapon GetNewWeapon(WeaponTypes weaponType, ProjectileTypes missileType = ProjectileTypes.AmbassadorMissile)
        {
            switch (weaponType)
            {
            case WeaponTypes.Laser:
                return(new Laser());

            case WeaponTypes.AltLaser:
                return(new AltLaser());

            case WeaponTypes.HurrDurr:
                return(new HurrDurr());

            case WeaponTypes.PlasmaCannon:
                return(new PlasmaCannon());

            case WeaponTypes.BC_Laser:
                return(new BC_Laser());

            case WeaponTypes.LaserWave:
                return(new LaserWave());

            case WeaponTypes.MissileLauncher:
                return(new MissileLauncher(missileType));

            case WeaponTypes.GravBomber:
                return(new GravBomber());

            case WeaponTypes.MineWeapon:
                return(new MineWeapon());



            case WeaponTypes.None:
                return(new NullWeapon());

            default:
                ConsoleManager.WriteLine("Error: " + weaponType.ToString() + " flyweight not yet implemented in WeaponManager.cs.", ConsoleMessageType.Error);
                return(new NullWeapon());
            }
        }
Example #27
0
        public bool TakeDamage(ProjectileTypes projectileType, byte pctCharge, float multiplier)
        {
            float damageAmount = this.DamageAmount(projectileType, pctCharge);

            _model.CurrentHealth -= damageAmount;


            if (_model.CurrentHealth <= 0)
            {
#if DEBUG
                if (_model.CurrentHealth < 0)
                {
                    ConsoleManager.WriteLine("Turret health is " + _model.CurrentHealth, ConsoleMessageType.Debug);
                }
#endif

                _model.CurrentHealth = 0;
                return(true);
            }
            return(false);
        }
Example #28
0
        public GameObject GetProjectile(ProjectileTypes projectileType)
        {
            foreach (GameObject projectile in projectilesTable[projectileType])
            {
                if (!projectile.activeInHierarchy)
                {
                    return(projectile);
                }
            }

            foreach (PoolProjectiles poolProjectile in poolProjectiles)
            {
                if (poolProjectile.projectileType == projectileType)
                {
                    GameObject projectile = Instantiate(poolProjectile.prefab);
                    projectilesTable[projectileType].Add(projectile);
                    projectile.transform.SetParent(poolProjectilesContainer.transform);
                    projectile.SetActive(false);
                    return(projectile);
                }
            }
            return(null);
        }
Example #29
0
    public void PlaceResource()
    {
        Debug.Log("Mouse down");
        if (selectedResource != null)
        {
            Vector3 mousePos = Input.mousePosition;
            Vector3 pos      = Camera.main.ScreenToWorldPoint(new Vector2(mousePos.x, mousePos.y));

            GameObject resource = Instantiate(selectedResource, new Vector3(Mathf.Round(pos.x), Mathf.Round(pos.y), 0), Quaternion.identity);

            if (selectedProjectile != ProjectileTypes.None)
            {
                resource.GetComponent <Scarecrow>().projectileType = selectedProjectile;
                currentResourcesDict[selectedProjectile]--;
            }
            else
            {
                currentTrees--;
            }
        }

        selectedProjectile = ProjectileTypes.None;
        selectedResource   = null;
    }
Example #30
0
        /// <summary>
        /// Sends damage amount to client
        /// Updates IShip health/shields appropriately
        /// Also handles projectile effects, if applicable
        /// </summary>
        /// <param name="projectileType"></param>
        /// <param name="projectileID"></param>
        /// <param name="pctCharge"></param>
        /// <param name="galaxyManager"></param>
        /// <returns>Returns true if the IShip is killed, false otherwise</returns>
        public bool TakeDamage(ProjectileTypes projectileType, byte pctCharge, float multiplier)
        {
            float damageAmount = this.DamageAmount(projectileType, pctCharge) / StatBonuses[StatBonusTypes.Defense] * (1 + Debuffs[DebuffTypes.Defense]);
            float energyAmount = this.EnergyAmount(projectileType, pctCharge) / StatBonuses[StatBonusTypes.Defense] * (1 + Debuffs[DebuffTypes.Defense]);

            ChangeEnergy(-energyAmount);

            TimeOfLastDamage = TimeKeeper.MsSinceInitialization;


            if (!IsDead)
            {
                if (Shields.CurrentShields == 0) //If shields are already at 0, player takes damage
                {
                    CurrentHealth -= damageAmount;
                }
                else if (Shields.CurrentShields - damageAmount < 0) //If there are not enough shields to take the damage
                {
                    Shields.CurrentShields = 0;
                }
                else
                {
                    Shields.CurrentShields -= damageAmount;
                }
            }


            if (CurrentHealth <= 0 && !IsDead)
            {
                return(true);
            }
            else //If IShip is not dead
            {
                return(false);
            }
        }
Example #31
0
 public void SetMissileType(ProjectileTypes missileType)
 {
     Stats = new MissileLauncherStats(missileType);
 }
Example #32
0
 public MissileLauncher(ProjectileManager projectileManager, ProjectileTypes missileType, Ship holdingObj, byte slot)
     : base(projectileManager, slot, holdingObj)
 {
     Stats = new MissileLauncherStats(missileType);
 }
Example #33
0
 public static ProjectileController CreateProjectile(float posX, float posY, ProjectileTypes projectile)
 {
     ProjectileController projectileController = null;
     try
     {
         projectileController = new ProjectileController(posX, posY, projectile);
     }
     catch (Exception)
     {
         // prefab loading failed.
     }
     return projectileController;
 }
 public ProjectileController(float posX, float posY, ProjectileTypes projectile)
     : base(posX,posY,projectile.ToString())
 {
 }