Exemplo n.º 1
0
 IEnumerator PowerUp(PowerUpItem item)
 {
     player.IncreasePlayerStatus(item);
     controller.SetObj(transform.position, BMObj.Empty);
     Destroy(gameObject);
     yield return(null);
 }
Exemplo n.º 2
0
        // パワーアップアイテムのレベルを指定
        public void SetPowerUpItemLevel(PowerUpItem kind, int level)
        {
            var key = kind.ToString();

            this.PowerUpItemLevels[key] = level;
            PlayerDataManager.DoUpdate();
        }
Exemplo n.º 3
0
    public void PurchaseItem(InputAction.CallbackContext context)
    {
        if (context.action.triggered)
        {
            int         money    = GameManager.Instance.money;
            PowerUpItem purchase = powerups[currentItem];

            if (currentItem == (int)PowerUp.RAPIDFIRE ||
                currentItem == (int)PowerUp.SHOTGUN)
            {
                if (GameManager.Instance.activePowerUps[currentItem] > 0)
                {
                    AudioManager.Instance.Play("MenuFail");
                    return;
                }
            }

            if (money < purchase.price)
            {
                AudioManager.Instance.Play("MenuFail");
            }
            else
            {
                AudioManager.Instance.Play("MenuBuy");
                GameManager.Instance.money -= purchase.price;
                GameManager.Instance.activePowerUps[purchase.index] += 1;
            }
        }
    }
Exemplo n.º 4
0
    void DisplayCurrentItem()
    {
        PowerUpItem current = powerups[currentItem];

        itemIcon.sprite = current.icon;
        itemName.text   = current.name;
        itemPrice.text  = current.price.ToString();
    }
Exemplo n.º 5
0
        // パワーアップアイテムのレベルを取得
        public int GetPoweUpItemLevel(PowerUpItem kind)
        {
            var key = kind.ToString();

            if (this.PowerUpItemLevels.ContainsKey(key))
            {
                return(this.PowerUpItemLevels[key]);
            }

            return(0);
        }
Exemplo n.º 6
0
    public void IncreasePlayerStatus(PowerUpItem itemNum)
    {
        // Debug.Log(name + "(IncreasePlayerStatus) itemNum=" + itemNum);
        // Debug.Log(name + "(IncreasePlayerStatus) PlayerStatus[(int)itemNum]=" + PlayerStatus[(int)itemNum] + "(before)");

        PlayerStatus[(int)itemNum]++;

        // Debug.Log(name + "(IncreasePlayerStatus) PlayerStatus[(int)itemNum]=" + PlayerStatus[(int)itemNum] + "(after)");

        /*
         * for (int i = 0; i < PlayerStatus.Length; i++)
         * {
         *  Debug.Log(i + ":" + (PowerUpItem)i + "=" + PlayerStatus[i]);
         * }
         */
    }
Exemplo n.º 7
0
        public void Start()
        {
            if (!Started)
            {
                elapsed = 0;
                Started = true;

                GameplayState gameplayState = Game.Instance.GameStateManager.States
                                              .FirstOrDefault(s => s is GameplayState)
                                              as GameplayState;

                PowerUpFactory powerUpFactory = new PowerUpFactory("JamGame.GameObjects.PowerUpItems");
                for (int i = 0; i < random.Next(3, 3 * gameplayState.Players.Length); i++)
                {
                    int         value   = random.Next(0, 100);
                    PowerUpItem powerUp = null;

                    if (Utils.InRange(0, 25, value))
                    {
                        Game.Instance.AddGameObject(powerUp = powerUpFactory.MakeNew("HealingPowerUp"));
                    }
                    else if (Utils.InRange(25, 50, value))
                    {
                        Game.Instance.AddGameObject(powerUp = powerUpFactory.MakeNew("IncreasedHpPowerUp"));
                    }
                    else if (Utils.InRange(50, 75, value))
                    {
                        Game.Instance.AddGameObject(powerUp = powerUpFactory.MakeNew("DoubleSpeedPowerUp"));
                    }
                    else if (Utils.InRange(75, 100, value))
                    {
                        Game.Instance.AddGameObject(powerUp = powerUpFactory.MakeNew("DoubleDamagePowerUp"));
                    }

                    powerUps.Add(powerUp);

                    powerUp.Position = new Vector2(
                        random.Next(0, Game.Instance.ScreenWidth - powerUp.Size.Width),
                        random.Next(Game.Instance.ScreenHeight / 2, Game.Instance.ScreenHeight - powerUp.Size.Height));
                }
            }
        }
Exemplo n.º 8
0
        private void GradeUp(PowerUpItem kind, bool isItem)
        {
            var dialog = BaseScene.AddModalWindow <DialogWindow>("DialogWindow");

            if (PlayerDataManager.PlayerData.StarNum >= (isItem ? this.itemNeedStar : this.openNeedStar))
            {
                dialog.SetDialog("確認", "", "よろしいですか?", null,
                                 () =>
                {
                    if (isItem)
                    {
                        Mission.GradeUpPowerUpItem(() =>
                        {
                            PlayerDataManager.PlayerData.StarNum -= this.itemNeedStar;
                            PlayerDataManager.PlayerData.SetPowerUpItemLevel(kind, PlayerDataManager.PlayerData.GetPoweUpItemLevel(kind) + 1);
                            //PlayerDataManager.Save();
                            MakeItemList();
                            dialog.onClose();
                        });
                    }
                    else
                    {
                        Mission.UnlockAnimalCar(() =>
                        {
                            PlayerDataManager.PlayerData.StarNum -= this.openNeedStar;
                            //PlayerDataManager.Save();
                            //MakeAnimalCarList();
                            dialog.onClose();
                        });
                    }
                }, () => { dialog.onClose(); });
            }
            else
            {
                dialog.SetDialog("確認", "", "スターが足りません。", () => { dialog.onClose(); }, null, null);
            }
        }
Exemplo n.º 9
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         PowerUpItem item = new PowerUpItem();
         foreach (PowerUpItem current in items)
         {
             if (current.cost >= item.cost && current.cost <= CoinBar.instance.currentCount &&
                 (item = current).cost == CoinBar.instance.currentCount)
             {
                 break;
             }
         }
         if (item.powerUp != null)
         {
             CoinBar.instance.AddCoins(-CoinBar.instance.currentCount);
             item.powerUp.Activate();
             if (item.powerUp.duration > 0.0F)
             {
                 PowerUpTimer.instance.setTimer(item.powerUp.imageIndex, item.powerUp.duration);
             }
         }
     }
 }
Exemplo n.º 10
0
 public static void IncreasePlayerStatusNum(PowerUpItem itemNum)
 {
     PlayerStatusNumArr[(int)itemNum]++;
 }
Exemplo n.º 11
0
 public static void SetPlayerStatusNum(PowerUpItem itemNum, int num)
 {
     PlayerStatusNumArr[(int)itemNum] = num;
 }
Exemplo n.º 12
0
 public static int GetPlayerStatusNum(PowerUpItem itemNum)
 {
     return(PlayerStatusNumArr[(int)itemNum]);
 }
Exemplo n.º 13
0
 public void DisablePowerUpItemForAllClients(PowerUpItem item)
 {
     item.PlayPickUpSound();
     item.spriteRenderer.enabled = false;
     item.mCollider.enabled      = false;
 }
Exemplo n.º 14
0
 public int GetPlayerStatus(PowerUpItem num)
 {
     return(PlayerStatus[(int)num]);
 }
Exemplo n.º 15
0
 void OnItemDestory(PowerUpItem item)
 {
     item.OnTriggerEntered -= this.OnPlayerTriggered;
     item.OnDestorySelf    -= this.OnItemDestory;
 }
Exemplo n.º 16
0
    /// <summary>
    /// Handles the collecting mechanism.
    /// </summary>
    /// <param name="collider">Colliding object parameter.</param>
    /// <returns></returns>
    void OnTriggerEnter(Collider collider)
    {
        if (collider.tag == "Player")
        {
            GetComponent <AudioSource>().Play();

            // Get the BasePlayer of the Game Object
            BasePlayer player = collider.GetComponent <BasePlayer>();
            player.PowerUpPickUpRumble();

            //==========================SETTING_PLAYERVALUES_TO_MAX_POWERUPS_START=======================
            // Check if the colliding object is a PowerUpEnam.addHealth
            if (type == PowerUpEnum.addHealth)
            {
                // Create new PowerUpAddHealth variable and add component of the PowerUpAddHealth
                PowerUpAddHealth AddHealth = player.gameObject.AddComponent <PowerUpAddHealth>();

                // Call Use on the player which has collected the powerup
                AddHealth.Use(player);
                //Destroy (AddHealth);
            }

            if (type == PowerUpEnum.addEnergy)
            {
                PowerUpAddEnergy AddEnergy = player.gameObject.AddComponent <PowerUpAddEnergy>();
                AddEnergy.Use(player);
                //Destroy (AddEnergy);
            }
            //==========================SETTING_PLAYERVALUES_TO_MAX_POWERUPS_END=========================

            //==================TEMPORARY_OR_PERMANENTLY_ADD_POWERUPS_START==============================
            if (type == PowerUpEnum.weaponDamage)
            {
                // If the gamedesigner want to add permanently the weapon damage OR there is no PowerUpWeaponDamage component on the player...
                if (addPermanently || player.gameObject.GetComponent <PowerUpWeaponDamage>() == null)
                {
                    // Then create a PowerUpWeaponDamage variable and...
                    PowerUpWeaponDamage AddDamage = player.gameObject.AddComponent <PowerUpWeaponDamage>();

                    // And call use of the vaiable
                    AddDamage.Use(player, outlastTime, powerUpValue, addPermanently);
                    //Destroy (AddDamage);
                }
                else if (!addPermanently)
                {
                    // Else get the component of the player...
                    PowerUpWeaponDamage AddDamage = player.gameObject.GetComponent <PowerUpWeaponDamage>();

                    // And call break and restart of the component
                    AddDamage.breakAndRestart();
                }
            }

            if (type == PowerUpEnum.weaponFireRate)
            {
                if (addPermanently || player.gameObject.GetComponent <PowerUpWeaponFireRate>() == null)
                {
                    PowerUpWeaponFireRate AddFireRate = player.gameObject.AddComponent <PowerUpWeaponFireRate>();
                    AddFireRate.Use(player, outlastTime, powerUpValue, addPermanently);
                    //Destroy (AddFireRate);
                }
                else if (!addPermanently)
                {
                    PowerUpWeaponFireRate AddFireRate = player.gameObject.GetComponent <PowerUpWeaponFireRate>();
                    AddFireRate.breakAndRestart();
                }
            }

            if (type == PowerUpEnum.lineCut)
            {
                // Only non permanent
                PowerUpCut lineCut = player.gameObject.GetComponent <PowerUpCut>();

                if (lineCut == null)
                {
                    lineCut                   = player.gameObject.AddComponent <PowerUpCut>();
                    lineCut.laserSound        = laserSound;
                    lineCut.volume            = volume;
                    lineCut.powerUpActiveTime = outlastTime;
                    lineCut.Use();
                }
                else
                {
                    lineCut.powerUpActiveTime = outlastTime;
                    lineCut.breakAndRestart();
                }
            }

            if (type == PowerUpEnum.mangoExplosion)
            {
                PowerUpMango mango = player.gameObject.AddComponent <PowerUpMango>();
                mango.SetExplosionProperties(explosionParticles, range);
                SoundManager.SoundManagerInstance.Play(clip, transform, 0.8f, 1, false, AudioGroup.Effects);
                mango.Use();
            }
            //==================TEMPORARY_OR_PERMANENTLY_ADD_POWERUPS_end================================

            //=============PROTOTYPE_POWERUPS_START==================
            if (type == PowerUpEnum.addMaxHealth)
            {
                PowerUpAddMaxHealth AddHealth = player.gameObject.AddComponent <PowerUpAddMaxHealth>();
                AddHealth.Use(player, powerUpValue);
                //Destroy (AddHealth);
            }

            if (type == PowerUpEnum.addMaxEnergy)
            {
                PowerUpAddMaxEnergy AddEnergy = player.gameObject.AddComponent <PowerUpAddMaxEnergy>();
                AddEnergy.Use(player, powerUpValue);
                //Destroy (AddEnergy);
            }
            //=============PROTOTYPE_POWERUPS_END====================

            // Trigger Event.
            if (!singlePowerUp)
            {
                CollectingPowerUp();
            }

            // Set the player as parent gameobject for the colliding object
            GameObject playerParent = collider.gameObject;
            int        i            = 0;
            while (i < playerParent.transform.childCount)
            {
                GameObject childObject = playerParent.transform.GetChild(i).gameObject;
                if (childObject != null)
                {
                    if (childObject.GetComponent <PowerUpItem>() != null)
                    {
                        PowerUpItem powerUpComponent = childObject.GetComponent <PowerUpItem>();
                        powerUpComponent.StopAllCoroutines();
                        //childObject.SetActive(false);
                        Destroy(childObject);
                    }
                }
                i++;
            }
            // Let the object pend over the player
            GameObject pendingObject = Instantiate(gameObject, new Vector3(playerParent.transform.position.x, playerParent.transform.position.y + 2.25f, playerParent.transform.position.z), transform.rotation) as GameObject;

            // Get the sphere collider of the pending object
            SphereCollider pendingSphereCollider = pendingObject.GetComponent <SphereCollider>();

            // Deactivate the collider to avoid colliding
            pendingSphereCollider.enabled = false;

            // Scale it down to prepare it for tweening
            pendingObject.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);

            // Start tweening coroutine with an animation curve
            StartCoroutine(Tween(pendingObject.transform, new Vector3(1f, 1f, 1f), 0.5f, AnimCurveContainer.AnimCurve.pingPong.Evaluate));

            // Start bck tweening coroutine
            StartCoroutine(TweenBack(pendingObject.transform, pendingTime));

            // Set the player to
            pendingObject.transform.SetParent(playerParent.transform, true);
            //Debug.Log (pendingObject.transform.localScale);
            Destroy(pendingObject, pendingTime);

            // Particle
            if (pickUpParticles != null)
            {
                Instantiate(pickUpParticles, transform.position, pickUpParticles.transform.rotation);
            }

            // send event
            new Event(Event.TYPE.powerup).addWave().addCharacter(player.PlayerIdentifier.ToString("g")).addPowerup(type.ToString()).addPos(this.transform).addLevel().send();
            MeshRenderer meshRenderer = transform.GetComponent <MeshRenderer>();

            // if the mesh renderer is in a childobject of the gameobject, then search all renderers of the child gameobject
            // and store it into an Renderer array, then disable all
            if (meshRenderer == null)
            {
                Renderer[] meshRendererArray = GetComponentsInChildren <Renderer>();
                foreach (Renderer renderer in meshRendererArray)
                {
                    renderer.enabled = false;
                }
            }
            else
            {
                // deactivate mesh renderer to hide the collectible item until it is destroyed
                meshRenderer.enabled = false;
            }

            ParticleSystem particleSystem = transform.GetComponent <ParticleSystem>();
            if (particleSystem == null)
            {
                ParticleSystem[] particleSystems = GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem particles in particleSystems)
                {
                    particles.emissionRate = 0.0F;
                }
            }
            else
            {
                // set particle emisiionrate to 0.0F to hide the collectible item until it is destroyed
                particleSystem.emissionRate = 0.0F;
            }

            // deactivate collider to prevent from multicasting the power up
            SphereCollider sphereCollider = transform.GetComponent <SphereCollider>();
            sphereCollider.enabled = false;

            DestroyCollectible(outlastTime);
        }
    }
Exemplo n.º 17
0
 public static ItemData Get(PowerUpItem type)
 {
     return(itemList[(int)type]);
 }
Exemplo n.º 18
0
 public void CmdDisableItemOnClients(PowerUpItem item)
 {
     DisablePowerUpItemForAllClients(item);
 }
Exemplo n.º 19
0
    /// <summary>
    /// Handles the collecting mechanism.
    /// </summary>
    /// <param name="collider">Colliding object parameter.</param>
    /// <returns></returns>
    void OnTriggerEnter(Collider collider)
    {
        if (collider.tag == "Player")
        {
            // Get the BasePlayer of the Game Object
            BasePlayer player = collider.GetComponent <BasePlayer>();

            // Trigger Event.
            CollectingPowerUp();

            // Set the player as parent gameobject for the colliding object
            GameObject playerParent = collider.gameObject;
            int        i            = 0;
            while (i < playerParent.transform.childCount)
            {
                GameObject childObject = playerParent.transform.GetChild(i).gameObject;
                if (childObject != null)
                {
                    if (childObject.GetComponent <PowerUpItem>() != null)
                    {
                        PowerUpItem powerUpComponent = childObject.GetComponent <PowerUpItem>();
                        powerUpComponent.StopAllCoroutines();
                        //childObject.SetActive(false);
                        Destroy(childObject);
                    }
                }
                i++;
            }
            // Let the object pend over the player
            GameObject pendingObject = Instantiate(gameObject, new Vector3(playerParent.transform.position.x, playerParent.transform.position.y + 2.25f, playerParent.transform.position.z), transform.rotation) as GameObject;

            // Get the sphere collider of the pending object
            SphereCollider pendingSphereCollider = pendingObject.GetComponent <SphereCollider>();

            // Deactivate the collider to avoid colliding
            pendingSphereCollider.enabled = false;

            // Scale it down to prepare it for tweening
            pendingObject.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);

            // Start tweening coroutine with an animation curve
            StartCoroutine(Tween(pendingObject.transform, new Vector3(1f, 1f, 1f), 0.5f, AnimCurveContainer.AnimCurve.pingPong.Evaluate));

            // Start bck tweening coroutine
            StartCoroutine(TweenBack(pendingObject.transform, pendingTime));

            // Set the player to
            pendingObject.transform.SetParent(playerParent.transform, true);
            //Debug.Log (pendingObject.transform.localScale);
            Destroy(pendingObject, pendingTime);

            // Particle
            if (pickUpParticles != null)
            {
                Instantiate(pickUpParticles, transform.position, pickUpParticles.transform.rotation);
            }

            // send event
            new Event(Event.TYPE.powerup).addWave().addCharacter(player.PlayerIdentifier.ToString("g")).addPowerup("specialPowerup").addPos(this.transform).addLevel().send();
            MeshRenderer meshRenderer = transform.GetComponent <MeshRenderer>();

            // if the mesh renderer is in a childobject of the gameobject, then search all renderers of the child gameobject
            // and store it into an Renderer array, then disable all
            if (meshRenderer == null)
            {
                Renderer[] meshRendererArray = GetComponentsInChildren <Renderer>();
                foreach (Renderer renderer in meshRendererArray)
                {
                    renderer.enabled = false;
                }
            }
            else
            {
                // deactivate mesh renderer to hide the collectible item until it is destroyed
                meshRenderer.enabled = false;
            }

            ParticleSystem particleSystem = transform.GetComponent <ParticleSystem>();
            if (particleSystem == null)
            {
                ParticleSystem[] particleSystems = GetComponentsInChildren <ParticleSystem>();
                foreach (ParticleSystem particles in particleSystems)
                {
                    particles.emissionRate = 0.0F;
                }
            }
            else
            {
                // set particle emisiionrate to 0.0F to hide the collectible item until it is destroyed
                particleSystem.emissionRate = 0.0F;
            }

            // deactivate collider to prevent from multicasting the power up
            SphereCollider sphereCollider = transform.GetComponent <SphereCollider>();
            sphereCollider.enabled = false;

            Destroy(this);
        }
    }