示例#1
0
    private void Awake()
    {
        GameObject playerGameObject = GameObject.FindWithTag(_tag.ToString());

        UnityEngine.Assertions.Assert.IsNotNull(playerGameObject, "Can't find a player gameobject with " + _tag.ToString().ToLower());

        _player       = playerGameObject.GetComponent <PlayerController>();
        _textAnimator = _text.GetComponent <Animator>();

        UnityEngine.Assertions.Assert.IsNotNull(_player, "Can't find a PlayerController attached");
    }
 public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         BooleanTag boolean = BooleanTag.TryFor(entry.GetArgumentObject(queue, 1));
         if (boolean == null)
         {
             queue.HandleError(entry, "Invalid boolean!");
             return;
         }
         PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));
         if (player == null)
         {
             queue.HandleError(entry, "Invalid player!");
             return;
         }
         bool       value = boolean.Internal;
         PlayerLife life  = player.Internal.player.life;
         if (life.isBroken != value)
         {
             if (value)
             {
                 life.breakLegs();
             }
             else
             {
                 life._isBroken = false;
                 life.channel.send("tellBroken", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                 {
                     life._isBroken
                 });
             }
             entry.Good(queue, "Successfully adjusted the broken legs of player " + TagParser.Escape(player.ToString()) + " to " + TagParser.Escape(boolean.ToString()) + "!");
         }
         else
         {
             entry.Good(queue, "Player " + TagParser.Escape(player.ToString()) + " already has their broken legs set to " + TagParser.Escape(boolean.ToString()) + "!");
         }
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to adjust player's broken legs: " + ex.ToString());
     }
 }
示例#3
0
        public void HitFlag(GameObjects.GameObject mario, Flagpole flagpole)
        {
            PlayerTag player = FindTagOfMario(mario);

            if (!playersFinished.Contains(player))
            {
                List <GameObjects.GameObject> flagpoles = currentLevel.GetFlagpoles();
                PlayerTag tag = FindTagOfMario(mario);
                if (!checkPoint.ContainsKey(tag) ||
                    flagpole.Location().X > checkPoint[tag].Location().X)
                {
                    SoundEffectManager.Instance.PauseBackgroundMusic();
                    SoundEffectManager.Instance.PlaySoundEffect(SoundEffectManager.SoundEffectTag.StageClear);
                    checkPoint[tag] = flagpole;
                    Flagpole lastFlagpole = flagpole;
                    foreach (Flagpole pole in flagpoles)
                    {
                        if (pole.Location().X > lastFlagpole.Location().X)
                        {
                            lastFlagpole = pole;
                        }
                    }
                    if (flagpole == lastFlagpole)
                    {
                        playersFinished.Add(player);
                        //Give points
                        scoreBoards[tag].AddPoints(Config.GetPointsPerSecond() * GetSecondsElapsed());
                        if (playersFinished.Count >= marios.Count)
                        {
                            //Determine Winner
                            PlayerTag winner = DetermineWinner();
                            //Change to winner state
                            GameState = new WinnerState(winner.ToString(), content, screenWidth, levels.ToArray());
                        }
                    }
                }
            }
        }