예제 #1
0
 /// <summary>
 /// 攻撃された
 /// </summary>
 private void OnAttacked(ObjectAttacker2D attacker)
 {
     if (indicator)
     {
         //値の反映
         indicator.SetRatio(attackable.HP, attackable.NowHP);
     }
     else
     {
         //表示器の取得
         var sManager = StageManager.Instance;
         if (sManager && sManager.IndicatorPool)
         {
             indicator = sManager.IndicatorPool.GetObject();
             indicator.Tracker.Target = transform;
             indicator.SetRatio(attackable.HP, attackable.NowHP);
         }
     }
 }
예제 #2
0
    public void Update()
    {
        if (beginCount < beginTime)
        {
            beginCount      += UnityEngine.Time.deltaTime;
            clock.percentage = 1.0f;
        }
        else if (beginningLabel.alpha > 0)
        {
            beginningLabel.alpha      -= .3f * UnityEngine.Time.deltaTime;
            beginningLabelShadow.alpha = beginningLabel.alpha;
        }
        enemyClock.percentage = (playerList.Count - 1) / startNumPlayers;
        if (playerList.Count == 1)
        {
            clock.disableClock();
            if (endScreen == null)
            {
                FSoundManager.PlaySound("win");
                endScreen = new LevelOverScreen(true, currentLevelNum + 1 >= enemiesOnLevel.Length);
                gui.AddChild(endScreen);
            }
            else
            {
                if (endScreen.readyToStart)
                {
                    Futile.instance.SignalUpdate -= Update;
                    Futile.stage.RemoveAllChildren();
                    if (this.currentLevelNum + 1 < enemiesOnLevel.Length)
                    {
                        World newWorld = new World(++this.currentLevelNum);
                        Futile.instance.SignalUpdate += newWorld.Update;
                    }
                    else
                    {
                        TitleScreen titleScreen = new TitleScreen();
                        Futile.stage.AddChild(titleScreen);
                    }
                }
            }
        }
        else if (clock.percentage <= 0)
        {
            if (endScreen == null)
            {
                FSoundManager.PlaySound("lose");
                endScreen = new LevelOverScreen(false);
                gui.AddChild(endScreen);
            }
            else
            {
                endScreen.MoveToFront();
                if (endScreen.readyToStart)
                {
                    Futile.instance.SignalUpdate -= Update;
                    Futile.stage.RemoveAllChildren();

                    World newWorld = new World(this.currentLevelNum);
                    Futile.instance.SignalUpdate += newWorld.Update;
                }
            }
        }
        for (int ind = 0; ind < powerups.Count; ind++)
        {
            Powerup powerup = powerups[ind];
            foreach (Player p in playerList)
            {
                if (p.isControlled)
                {
                    if (powerup.checkCollision(p))
                    {
                        FSoundManager.PlaySound("powerup");
                        p.collectPowerUp(powerup.PType);
                        powerup.RemoveFromContainer();
                        powerups.Remove(powerup);
                        ind--;
                    }
                }
            }
        }
        for (int ind = 0; ind < bulletList.Count; ind++)
        {
            Bullet b = bulletList[ind];
            b.Update();
            for (int playerInd = 0; playerInd < playerList.Count; playerInd++)
            {
                Player p = playerList[playerInd];
                if (clock.percentage > 0 && b.checkCollision(p))
                {
                    p.setScale(p.scale - 1.0f, false);
                    if (p.scale <= 0)
                    {
                        FSoundManager.PlaySound("dead", .3f);
                        p.RemoveFromContainer();
                        playerList.Remove(p);
                        playerInd--;
                        FloatIndicator floatInd = new FloatIndicator("+00:00:0" + p.secondValue, p.GetPosition());
                        playerLayer.AddChild(floatInd);
                        clock.percentage += p.secondValue / 10.0f;      //Add the seconds to the clock
                        if (p.secondValue == 3)
                        {
                            float   powerupChance = RXRandom.Float();
                            Powerup powerup       = null;
                            if (powerupChance < .4f)
                            {
                                powerup = new Powerup(Powerup.PowerupType.MACHINEGUN);
                            }
                            else if (powerupChance < .8f)
                            {
                                powerup = new Powerup(Powerup.PowerupType.SHOTGUN);
                            }
                            if (powerup != null)
                            {
                                powerups.Add(powerup);
                                powerup.SetPosition(p.GetPosition());
                                playerLayer.AddChild(powerup);
                            }
                        }
                    }
                    else
                    {
                        FSoundManager.PlaySound("hit", .3f);
                    }
                    b.RemoveFromContainer();
                    bulletList.Remove(b);
                    ind--;
                    break;
                }
                else
                if (tilemap.getFrameNum((int)(b.x / tilemap._tileWidth), (int)(-b.y / tilemap._tileHeight)) == 1)
                {
                    b.RemoveFromContainer();
                    bulletList.Remove(b);
                    ind--;
                    break;
                }
            }
        }
    }