コード例 #1
0
    public void CreateItem(ItemType itemType, int row, int col)
    {
        bool isSpeedUp  = false;
        bool isAutoMove = false;

        GameObject toSpawn = null;

        switch (itemType)
        {
        case ItemType.SpeedUpItem:
            toSpawn   = speedUpItem;
            isSpeedUp = true;
            break;

        case ItemType.SpeedUpItemSpace:
            toSpawn   = speedUpItemSpace;
            isSpeedUp = true;
            break;

        case ItemType.DragonflyItem:
            toSpawn    = dragonflyItem;
            isSpeedUp  = true;
            isAutoMove = true;
            break;

        case ItemType.DragonflyItemSpace:
            toSpawn    = dragonflyItemSpace;
            isSpeedUp  = true;
            isAutoMove = true;
            break;

        default:
            Debug.LogError("ItemManager#CreateItemAtPosition: Unhandled item type!");
            return;
        }

        GameObject item = Instantiate(
            toSpawn,
            Level.GetSingleton().GetLilypadOriginWorldCoordinate(row, col),
            Quaternion.identity);

        if (isSpeedUp)
        {
            SpeedUpItem speedUpItemScript = item.GetComponent <SpeedUpItem>();
            speedUpItemScript.SpawnAt(row, col);
            speedUpItemScript.enabled = true;
        }
        if (isAutoMove)
        {
            AutoMove autoMoveScript = item.GetComponent <AutoMove>();
            autoMoveScript.SpawnAt(row, col);
        }
    }
コード例 #2
0
 public static void finish(string itemName, Player currentPlayer)
 {
     if (itemName == "SpeedDownItem")
     {
         SpeedDownItem.finish(currentPlayer);
     }
     else if (itemName == "SpeedUpItem")
     {
         SpeedUpItem.finish(currentPlayer);
     }
     else if (itemName == "MissileItem")
     {
         MissileItem.finish(currentPlayer);
     }
     else if (itemName == "BananaItem")
     {
         BananaItem.finish(currentPlayer);
     }
 }
コード例 #3
0
 public static void use(string itemName, Player currentPlayer)
 {
     getPlayers();
     if (itemName == "SpeedDownItem")
     {
         SpeedDownItem.use(currentPlayer, targetPlayers);
     }
     else if (itemName == "SpeedUpItem")
     {
         SpeedUpItem.use(currentPlayer, targetPlayers);
     }
     else if (itemName == "MissileItem")
     {
         MissileItem.use(currentPlayer, targetPlayers);
     }
     else if (itemName == "BananaItem")
     {
         BananaItem.use(currentPlayer, targetPlayers);
     }
 }
コード例 #4
0
 public static void execute(string itemName, Player currentPlayer)
 {
     if (itemName == "SpeedDownItem")
     {
         SpeedDownItem.execute(currentPlayer);
     }
     else if (itemName == "SpeedUpItem")
     {
         SpeedUpItem.execute(currentPlayer);
     }
     else if (itemName == "MissileItem")
     {
         MissileItem.execute(currentPlayer);
     }
     else if (itemName == "BananaItem")
     {
         BananaItem.execute(currentPlayer);
     }
     else if (itemName == "ShieldItem")
     {
         ShieldItem.execute(currentPlayer);
     }
 }
コード例 #5
0
ファイル: FieldItem.cs プロジェクト: mecha-rm/GDW_Y3-PJT
    // adds the item component to the player
    public HeldItem AddItemComponent(PlayerObject player)
    {
        // generated item
        HeldItem genItem = null;

        // checks to see which item to set.
        switch (itemSet)
        {
        case 0:     // none
            break;

        case itemType.speedUp:     // speed up
            // checks to see if the player already has a speed item attached.
            SpeedUpItem speedUp = player.gameObject.GetComponent <SpeedUpItem>();

            // if the player already has a speed item, the countdown for it is reset.
            // if they didn't have a speed item, they are given one.
            if (speedUp == null)
            {
                // checks to see if a speed down component is equipped.
                // if so, deactive it first.
                SpeedDownItem oppItem = player.gameObject.GetComponent <SpeedDownItem>();

                // deactive effect
                if (oppItem != null)
                {
                    oppItem.DeactiveEffect();
                }

                genItem = player.gameObject.AddComponent <SpeedUpItem>();
            }
            else
            {
                speedUp.ResetCountdown();
            }

            break;

        case itemType.speedDown:     // speed down
            // checks to see if the player already has a speed item attached.
            SpeedDownItem speedDown = player.gameObject.GetComponent <SpeedDownItem>();

            // if the player already has a speed item, the countdown for it is reset.
            // if they didn't have a speed item, they are given one.
            if (speedDown == null)
            {
                // checks to see if a speed up component is equipped.
                // if so, deactive it first.
                SpeedUpItem oppItem = player.gameObject.GetComponent <SpeedUpItem>();

                // deactive effect
                if (oppItem != null)
                {
                    oppItem.DeactiveEffect();
                }

                genItem = player.gameObject.AddComponent <SpeedDownItem>();
            }
            else
            {
                speedDown.ResetCountdown();
            }

            break;

        case itemType.jumpUp:     // jump up
            // checks to see if the player already has a jump item attached.
            JumpUpItem jumpItem = player.gameObject.GetComponent <JumpUpItem>();

            // if the player already has a jump item, the countdown for it is reset.
            // if they didn't have a jump item, they are given one.
            if (jumpItem == null)
            {
                // checks for jump down item and deactives it if needed.
                JumpDownItem oppItem = player.gameObject.GetComponent <JumpDownItem>();

                // deactive effect
                if (oppItem != null)
                {
                    oppItem.DeactiveEffect();
                }

                genItem = player.gameObject.AddComponent <JumpUpItem>();
            }
            else
            {
                jumpItem.ResetCountdown();
            }

            break;

        case itemType.jumpDown:     // jump down
            // checks to see if the player already has a jump item attached.
            JumpDownItem jumpDown = player.gameObject.GetComponent <JumpDownItem>();

            // if the player already has a jump item, the countdown for it is reset.
            // if they didn't have a jump item, they are given one.
            if (jumpDown == null)
            {
                // checks for jump down item and deactives it if needed.
                JumpUpItem oppItem = player.gameObject.GetComponent <JumpUpItem>();

                // deactive effect
                if (oppItem != null)
                {
                    oppItem.DeactiveEffect();
                }

                genItem = player.gameObject.AddComponent <JumpDownItem>();
            }
            else
            {
                jumpDown.ResetCountdown();
            }

            break;

        case itemType.scaleUp:     // scale up
            // checks to see if the player already has a jump item attached.
            ScaleUpItem scaleUp = player.gameObject.GetComponent <ScaleUpItem>();

            // if the player already has this item, it adds to its time. If they don't, then they're given one.
            if (scaleUp == null)
            {
                // checks for scale down item and deactives it if needed.
                ScaleDownItem oppItem = player.gameObject.GetComponent <ScaleDownItem>();

                // deactive effect
                if (oppItem != null)
                {
                    oppItem.DeactiveEffect();
                }

                genItem = player.gameObject.AddComponent <ScaleUpItem>();
            }
            else
            {
                scaleUp.ResetCountdown();
            }

            break;

        case itemType.scaleDown:     // scale down
            // checks to see if the player already has a jump item attached.
            ScaleDownItem scaleDown = player.gameObject.GetComponent <ScaleDownItem>();

            // if the player already has this item, it adds to its time. If they don't, then they're given one.
            if (scaleDown == null)
            {
                // checks for scale up item and deactives it if needed.
                ScaleUpItem oppItem = player.gameObject.GetComponent <ScaleUpItem>();

                // deactive effect
                if (oppItem != null)
                {
                    oppItem.DeactiveEffect();
                }

                genItem = player.gameObject.AddComponent <ScaleDownItem>();
            }
            else
            {
                scaleDown.ResetCountdown();
            }

            break;
        }

        // activates the effect.
        if (genItem != null)
        {
            genItem.ActivateEffect(player);
        }

        return(genItem);
    }