コード例 #1
0
        public ActionStates Update(BehaviourTree tree)
        {
            if (State == ActionStates.None)
            {
                if (tree != null)
                    tree.Execution.Push(this);

                OnBegin();
            }

            // Check in case an Update is called after the task is done.
            if (State == ActionStates.Running)
                State = OnExecute(tree);

            if (State != ActionStates.Running)
            {
                OnEnd();

                if (tree != null)
                {
                    tree.Execution.Pop();

                    if (tree.Execution.Count > 0)
                        return tree.Execution.Peek().Update(tree);
                }
            }

            return State;
        }
コード例 #2
0
 //Action States handlers
 void UpdateIdle()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         if (shovelCount > 0)
         {
             actionStates = ActionStates.tunneling;
         }
     }
 }
コード例 #3
0
ファイル: ActionServer.cs プロジェクト: Hubinatorr/Bakalarka
        protected abstract void GoalHandle(Tgoal goal); // to be implemented by user

        protected void Start()
        {
            rosSocket   = GetComponent <RosConnector>().RosSocket;
            ActionState = ActionStates.Pending;

            rosSocket.Subscribe <Messages.Actionlib.GoalID>(ActionName + "/cancel", CancelCallback, (int)(TimeStep * 1000));
            rosSocket.Subscribe <Tgoal>(ActionName + "/goal", GoalCallback, (int)(TimeStep * 1000));

            StatusPublicationId   = rosSocket.Advertise <Messages.Actionlib.GoalStatusArray>(ActionName + "/status");
            FeedbackPublicationId = rosSocket.Advertise <Tfeedback>(ActionName + "/feedback");
            ResultPublicationId   = rosSocket.Advertise <Tresult>(ActionName + "/result");
        }
コード例 #4
0
        public SecretAnnouncement(string name, Dictionary <string, Agent> allAgents, Dictionary <string, Agent> audience, Formula announcement)
            : base(name, allAgents, audience, announcement)
        {
            ActionState trueState = new ActionState("TrueState");

            SecretState = new ActionState("Secret");
            SecretState.Precondition = announcement;
            ActionStates.Add(trueState);
            ActionStates.Add(SecretState);

            Relation             = new ActionIndecisionPair(SecretState, trueState);
            Relation.TagedAgents = GetSubtractionOfAgentDics(allAgents, audience);
            TransitionRelation.Add(Relation);
        }
コード例 #5
0
ファイル: ServerPlayer.cs プロジェクト: Galli24/RetroGame
        public void Update(float fixedDeltaTime)
        {
            var p     = Vector2.Zero;
            var speed = Player.SPEED;

            foreach (var action in ActionStates.Where(action => action.Value))
            {
                switch (action.Key)
                {
                case Actions.MOVE_LEFT:
                    p.X -= 1;
                    break;

                case Actions.MOVE_RIGHT:
                    p.X += 1;
                    break;

                case Actions.MOVE_DOWN:
                    p.Y -= 1;
                    break;

                case Actions.MOVE_UP:
                    p.Y += 1;
                    break;

                case Actions.BOOST:
                    speed = 1000;
                    break;

                case Actions.SHOOT:
                    if (ShootCooldown <= 0)
                    {
                        ShootCooldown = SHOOT_COOLDOWN_TIME;
                        _gameManager.AddBullet(new Vector2(Position.X, Position.Y));
                    }
                    else
                    {
                        ShootCooldown -= fixedDeltaTime;
                    }
                    break;
                }
            }

            if (p != Vector2.Zero)
            {
                Position += p * fixedDeltaTime * speed;
                Position  = Vector2.Clamp(Position, Vector2.Zero, new Vector2(1920, 1080) - new Vector2(100)); // - player size
            }
        }
コード例 #6
0
    void UpdatePlayerLostLife()
    {
        if (player.Lives > 0)
        {
            DeStunPlayer();
            flashSprites = true;

            playerAnim.SetBool("DigDown", false);
            canTunnel = false;
            tunnel    = false;
        }

        actionStates = ActionStates.idle;
        playerStates = States.playerAlive;
    }
コード例 #7
0
 public void ExecuteAction(ActionStates state)
 {
     Debug.Log("Execute Action:" + state.ToString());
     if (state == ActionStates.QUICK_ATTACK)
     {
         StartCoroutine(executeAction("IsAttack", false));
     }
     else if (state == ActionStates.BLOCK)
     {
         StartCoroutine(executeAction("IsBlock", false));
     }
     else if (state == ActionStates.SPELL)
     {
         StartCoroutine(executeAction("IsSpell", true));
     }
 }
コード例 #8
0
    private void OnActionStateChanged(ActionStates state)
    {
        switch (state)
        {
        case ActionStates.Idel:
            if (!_animator.GetBool(DragonAnimationTriggers.Idel.ToString()))
            {
                _animator.SetTrigger(DragonAnimationTriggers.Idel.ToString());
            }
            break;

        case ActionStates.Fly:
            if (!_animator.GetBool(DragonAnimationTriggers.Fly.ToString()))
            {
                _animator.SetTrigger(DragonAnimationTriggers.Fly.ToString());
            }
            break;
        }
    }
コード例 #9
0
 private ActionsPaneRootData ReadNextActions()
 {
     ActionsPaneRootData data = new ActionsPaneRootData();
     int length = this._source.Get_Actions_Id_Count()[this._currentIndex];
     int[] destinationArray = null;
     if (length >= 0)
     {
         destinationArray = new int[length];
         Array.Copy(this._source.Get_Actions_Id(), this._Actions_Id_Offset, destinationArray, 0, length);
         this._Actions_Id_Offset += length;
     }
     data.SetId(destinationArray);
     int num2 = this._source.Get_Actions_ItemType_Count()[this._currentIndex];
     ActionsPaneRootItemType[] typeArray = null;
     if (num2 >= 0)
     {
         typeArray = new ActionsPaneRootItemType[num2];
     }
     int index = 0;
     for (index = 0; index < num2; index++)
     {
         typeArray[index] = (ActionsPaneRootItemType) this._source.Get_Actions_ItemType()[this._Actions_ItemType_Offset];
         this._Actions_ItemType_Offset++;
     }
     data.SetItemType(typeArray);
     int num4 = this._source.Get_Actions_InsertionLocation_Count()[this._currentIndex];
     ActionsInsertionLocation[] locationArray = null;
     if (num4 >= 0)
     {
         locationArray = new ActionsInsertionLocation[num4];
     }
     int num5 = 0;
     for (num5 = 0; num5 < num4; num5++)
     {
         locationArray[num5] = (ActionsInsertionLocation) this._source.Get_Actions_InsertionLocation()[this._Actions_InsertionLocation_Offset];
         this._Actions_InsertionLocation_Offset++;
     }
     data.SetInsertionLocation(locationArray);
     int num6 = this._source.Get_Actions_DisplayName_Count()[this._currentIndex];
     string[] strArray = null;
     if (num6 >= 0)
     {
         strArray = new string[num6];
     }
     int num7 = 0;
     for (num7 = 0; num7 < num6; num7++)
     {
         strArray[num7] = this._strings.ReadString();
         this._Actions_DisplayName_Offset++;
     }
     data.SetDisplayName(strArray);
     int num8 = this._source.Get_Actions_MnemonicDisplayName_Count()[this._currentIndex];
     string[] strArray2 = null;
     if (num8 >= 0)
     {
         strArray2 = new string[num8];
     }
     int num9 = 0;
     for (num9 = 0; num9 < num8; num9++)
     {
         strArray2[num9] = this._strings.ReadString();
         this._Actions_MnemonicDisplayName_Offset++;
     }
     data.SetMnemonicDisplayName(strArray2);
     int num10 = this._source.Get_Actions_Description_Count()[this._currentIndex];
     string[] strArray3 = null;
     if (num10 >= 0)
     {
         strArray3 = new string[num10];
     }
     int num11 = 0;
     for (num11 = 0; num11 < num10; num11++)
     {
         strArray3[num11] = this._strings.ReadString();
         this._Actions_Description_Offset++;
     }
     data.SetDescription(strArray3);
     int num12 = this._source.Get_Actions_LanguageIndependentName_Count()[this._currentIndex];
     string[] strArray4 = null;
     if (num12 >= 0)
     {
         strArray4 = new string[num12];
     }
     int num13 = 0;
     for (num13 = 0; num13 < num12; num13++)
     {
         strArray4[num13] = this._strings.ReadString();
         this._Actions_LanguageIndependentName_Offset++;
     }
     data.SetLanguageIndependentName(strArray4);
     int num14 = this._source.Get_Actions_ImageIndex_Count()[this._currentIndex];
     int[] numArray2 = null;
     if (num14 >= 0)
     {
         numArray2 = new int[num14];
         Array.Copy(this._source.Get_Actions_ImageIndex(), this._Actions_ImageIndex_Offset, numArray2, 0, num14);
         this._Actions_ImageIndex_Offset += num14;
     }
     data.SetImageIndex(numArray2);
     int num15 = this._source.Get_Actions_State_Count()[this._currentIndex];
     ActionStates[] statesArray = null;
     if (num15 >= 0)
     {
         statesArray = new ActionStates[num15];
     }
     int num16 = 0;
     for (num16 = 0; num16 < num15; num16++)
     {
         statesArray[num16] = (ActionStates) this._source.Get_Actions_State()[this._Actions_State_Offset];
         this._Actions_State_Offset++;
     }
     data.SetState(statesArray);
     int num17 = this._source.Get_Actions_ExecuteSync_Count()[this._currentIndex];
     bool[] flagArray = null;
     if (num17 >= 0)
     {
         flagArray = new bool[num17];
         Array.Copy(this._source.Get_Actions_ExecuteSync(), this._Actions_ExecuteSync_Offset, flagArray, 0, num17);
         this._Actions_ExecuteSync_Offset += num17;
     }
     data.SetExecuteSync(flagArray);
     int num18 = this._source.Get_Actions_RenderAsRegion_Count()[this._currentIndex];
     bool[] flagArray2 = null;
     if (num18 >= 0)
     {
         flagArray2 = new bool[num18];
         Array.Copy(this._source.Get_Actions_RenderAsRegion(), this._Actions_RenderAsRegion_Offset, flagArray2, 0, num18);
         this._Actions_RenderAsRegion_Offset += num18;
     }
     data.SetRenderAsRegion(flagArray2);
     int num19 = this._source.Get_Actions_ItemsCount_Count()[this._currentIndex];
     int[] numArray3 = null;
     if (num19 >= 0)
     {
         numArray3 = new int[num19];
         Array.Copy(this._source.Get_Actions_ItemsCount(), this._Actions_ItemsCount_Offset, numArray3, 0, num19);
         this._Actions_ItemsCount_Offset += num19;
     }
     data.SetItemsCount(numArray3);
     return data;
 }
コード例 #10
0
 public void SetState(ActionStates[] value)
 {
     this._state = value;
 }
コード例 #11
0
    void UpdateTunneling()
    {
        //get the end tile based on hov many shovels the player is carrying
        int travelTilesAmount;

        travelTilesAmount = tunnelDistance;
        IntPosition2D endPos = new IntPosition2D(player.IntPos.X, player.IntPos.Y + travelTilesAmount);

        //check if end tile is walkable

        try
        {
            if (GM.World.Tiles [endPos.X, endPos.Y].Walkable == true)
            {
                Debug.Log("i can tunnel to the end!");
                canTunnel = true;
            }
            else
            {
                Debug.Log("i Can't tunnel to the end");
                canTunnel = false;
            }
        } catch
        {
            canTunnel = false;
        }


        //transport player && remove shovels
        if (Input.GetKeyDown(KeyCode.Q))
        {
            actionStates = ActionStates.idle;
            canTunnel    = false;
            tunnel       = false;
        }
        if (canTunnel && !tunnel && Input.GetKeyDown(KeyCode.Alpha1))
        {
            hudGizmos.clearHUD = true;
            StunPlayer();
            playerAnim.SetBool("DigDown", true);
            tunnel         = true;
            player.Imortal = true;
        }

        if (tunnel)
        {
            if (tpPlayer(new Vector2(endPos.X, endPos.Y), 0.5f))
            {
                shovelCount--;
                playerAnim.SetBool("DigDown", false);
            }

            if (DeStunPlayerDelay(0.9f))
            {
                canTunnel          = false;
                tunnel             = false;
                player.Imortal     = false;
                tpDelayTimer       = 0f;
                hudGizmos.clearHUD = false;
                actionStates       = ActionStates.idle;
            }
        }
    }
コード例 #12
0
        private IActionResult AddState(Guid actionGuid, String statusValue, String message = null)
        {
            if (actionGuid == Guid.Empty)
            {
                return(Problem("Empty GUID is invalid."));
            }

            if (String.IsNullOrEmpty(statusValue))
            {
                return(Problem("Status value is required."));
            }

            _logger.LogInformation("Enter AddState.");

            JsonResult result = null;

            using (var context = new PreIngestStatusContext())
            {
                var currentSession = context.Find <PreingestAction>(actionGuid);
                if (currentSession != null)
                {
                    var item = new ActionStates {
                        StatusId = Guid.NewGuid(), Creation = DateTimeOffset.Now, Name = statusValue, ProcessId = currentSession.ProcessId, Session = currentSession
                    };
                    context.Add <ActionStates>(item);
                    StateMessage stateMessage = null;
                    try
                    {
                        context.SaveChanges();

                        if (!String.IsNullOrEmpty(message))
                        {
                            stateMessage = new StateMessage
                            {
                                Creation    = DateTimeOffset.Now,
                                Description = message,
                                MessageId   = Guid.NewGuid(),
                                Status      = item,
                                StatusId    = item.StatusId
                            };
                            context.Add <StateMessage>(stateMessage);
                            try
                            {
                                context.SaveChanges();
                            }
                            catch (Exception e) { _logger.LogError(e, "An exception was thrown in {0}: '{1}'.", e.Message, e.StackTrace); }
                            finally { }
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e, "An exception was thrown : {0}, '{1}'.", e.Message, e.StackTrace);
                        return(ValidationProblem(String.Format("An exception was thrown : {0}, '{1}'.", e.Message, e.StackTrace)));
                    }
                    finally { }

                    if (stateMessage != null)
                    {
                        result = new JsonResult(new { item.StatusId, item.ProcessId, item.Creation, item.Name, Message = new { stateMessage.Creation, stateMessage.Description, stateMessage.MessageId, stateMessage.StatusId } });
                    }
                    else
                    {
                        result = new JsonResult(new { item.StatusId, item.ProcessId, item.Creation, item.Name });
                    }
                }
            }

            _logger.LogInformation("Exit AddState.");

            if (result == null)
            {
                return(NoContent());
            }

            return(result);
        }
コード例 #13
0
    IEnumerator simulation(int totalCount)
    {
        //fillPlayerActions.UpdateCanvas();
        yield return(new WaitForSeconds(.5f));

        PlayerPointerObject.gameObject.SetActive(true);
        EnemyPointerObject.gameObject.SetActive(true);
        for (int i = 0; i < totalCount; i++)
        {
            playerCurrentAction = CBM.PlayerActions[i];
            enemyCurrentAction  = EnemyActions[i];


            if (EnemyScriptCase.childCount >= i + 1)
            {
                EnemyBlockPos = EnemyScriptCase.GetChild(i);
            }

            if (PlayerScriptCase.childCount >= i + 1)
            {
                PlayerBlockPos = PlayerScriptCase.GetChild(i);
            }


            yield return(new WaitForSeconds(2f));

            Rules();
            yield return(new WaitForSeconds(.5f));

            //check here if someone is dead
        }

        //check here if player and enemy life is equal if yes declare a tie
        //if life is not equal repeat sequence
        AddtoConsole("Player:" + PlayerPoints + " points");
        AddtoConsole("Enemy:" + EnemyPoints + " points");
        Debug.Log("Player:" + PlayerPoints + " points");
        Debug.Log("Enemy:" + EnemyPoints + " points");
        if (PlayerPoints > EnemyPoints)
        {
            Debug.Log("PLAYER WINS!");
            AddtoConsole("Player wins!");
        }
        else if (PlayerPoints < EnemyPoints)
        {
            DebugMode();
            Debug.Log("ENEMY WINS!");
            AddtoConsole("Enemy Wins!");
        }
        else
        {
            DebugMode();
            Debug.Log("ITS A TIE");
            AddtoConsole("Its a tie");
        }
        Debug.Log("End of Simulation");
        AddtoConsole("End of Simulation");

        PlayerPointerObject.gameObject.SetActive(false);
        EnemyPointerObject.gameObject.SetActive(false);
        IsCompiling  = false;
        IsSimulating = false;

        Debug.Log("Comencing Script Battle!");
        yield return(new WaitForSeconds(2f));
    }
コード例 #14
0
 private void Idel()
 {
     ActionState = ActionStates.Idel;
 }
コード例 #15
0
 public void SetCondition(ActionStates con)
 {
     condition   = con;
     upText.text = "if <" + con.ToString() + ">";
 }
コード例 #16
0
    public int GetPlayerMoveCount(Transform content, int depth)
    {
        if (depth == 0)
        {
            pa.Clear();
        }
        ActionStates action       = ActionStates.NULL;
        Transform    currentBlock = content.GetChild(0);

        while (currentBlock != null)
        {
            CodeBlockMeta blockMeta = currentBlock.GetComponent <CodeBlockMeta>();

            if (blockMeta == null)
            {
                action = ActionStates.NULL;
                Debug.Log("NO ACTION FOUND!");
            }
            else if (blockMeta.type == "codeblock")
            {
                action = blockMeta.act;
            }
            else if (blockMeta.type == "decision")
            {
                if (GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>().actions.Count > PlayerActions.Count)
                {
                    currentEnemyAction = GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>().actions[PlayerActions.Count].Action;
                }
                else
                {
                    currentEnemyAction = ActionStates.GMODE;
                }
                if (GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>() == null)
                {
                    Debug.Log("Cannot find enemy manager!");
                }

                if (currentEnemyAction == blockMeta.condition)
                {
                    GetPlayerMoveCount(FindContentWithTag(currentBlock, "truecontent"), depth + 1);

                    action = ActionStates.NULL;
                }
                else
                {
                    GetPlayerMoveCount(FindContentWithTag(currentBlock, "falsecontent"), depth + 1);
                    action = ActionStates.NULL;
                }
            }
            else if (blockMeta.type == "repeat")
            {
                bool RepStep = blockMeta.RepeatStep();
                if (RepStep)
                {
                    blockMeta.RevertRepeat();
                    action = ActionStates.NULL;
                }
                else
                {
                    GetPlayerMoveCount(FindContentWithTag(currentBlock, "content"), depth + 1);
                    action = ActionStates.SPECIAL;
                }
            }


            if (action != ActionStates.NULL && action != ActionStates.SPECIAL)
            {
                pa.Add(action);
            }
            if (action != ActionStates.SPECIAL)
            {
                currentBlock = GetNext(currentBlock);
            }
        }


        if (depth == 0)
        {
            return(pa.Count);
        }

        return(0);
    }
コード例 #17
0
 public virtual void OnBegin()
 {
     State = ActionStates.Running;
 }
コード例 #18
0
ファイル: ActionStatus.cs プロジェクト: tbeaupre/SpaceCadet
 public ActionStatus(ActionStates state, int duration)
 {
     this.state    = state;
     this.duration = duration;
 }
コード例 #19
0
 public virtual void OnBegin()
 {
     State = ActionStates.Running;
 }
コード例 #20
0
 public void AssignDecision(ActionStates con)
 {
     dropped.GetComponent <CodeBlockMeta>().SetCondition(con);
     conditions.SetBool("IsOpen", false);
 }
コード例 #21
0
 public void ExecuteAction(ActionStates state)
 {
     Debug.Log("Execute Action:" + state.ToString());
 }
コード例 #22
0
ファイル: Buffalo.cs プロジェクト: colincapurso/IC2013
        public override void Update(GameTime gameTime)
        {
            float timeDelta = (float)gameTime.ElapsedGameTime.TotalSeconds;

              switch (ActionState)
              {
            case ActionStates.Standing:
              Velocity.X = 0;
              break;
            case ActionStates.PreCharge:
              Velocity.X = 0;

              Direction = DrawBox.Center.X < TargetPerson.DrawBox.Center.X ? 1 : -1;

              if (Game1.CurrentTime - PreChargeStart > PreChargeDuration)
            ChargePlayer();

              break;
            case ActionStates.ChasingPlayer:
              if (TargetPerson.State != Player.PlayerStates.KnockBack)
            Velocity.X = SPEED_CHASE * Math.Sign(TargetPerson.Hitbox.Center.X - Hitbox.Center.X);

              break;
            case ActionStates.Charging:
              // If you are currently charging, check that you are within the maximum duration
              if (Game1.CurrentTime - LastCharge > ChargeMaxDuration)
              {
            ActionState = ActionStates.Standing;
            GoNeutral();
            Velocity.X = 0;
            break;
              }

              // If you are currently charging, then check if you hit the player
              int directionFromPlayer = Math.Sign(TargetPerson.Hitbox.Center.X - Hitbox.Center.X);

              Vector2 buffaloHornPosition = new Vector2(Hitbox.Center.X + 84 * directionFromPlayer, Hitbox.Y + 46);

              // are horns are hitting player?
              if (TargetPerson.Hitbox.Over(buffaloHornPosition))
              {
            // then knockback player and stop
            Game1.EventMan.Notify(Events.KnockedBack, new ActiveObject[] { this, TargetPerson });
            ActionState = ActionStates.Standing;
            GoNeutral();
            Velocity.X = 0;
            break;
              }

              break;
              }

              UpdateMovement(gameTime);
        }
コード例 #23
0
    ActionStates CodeBlockReader(Transform block)
    {
        blockpos = block;
        CodeBlockMeta blockMeta = block.GetComponent <CodeBlockMeta>();

        if (blockMeta == null)
        {
            return(ActionStates.NULL);
        }
        if (blockMeta.type == "codeblock")
        {
            //Debug.Log("Executing Function:" + blockMeta.act);
            return(blockMeta.act);
        }
        if (blockMeta.type == "decision")
        {
            if (GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>().actions.Count > PlayerActions.Count)
            {
                currentEnemyAction = GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>().actions[PlayerActions.Count].Action;
            }
            else
            {
                currentEnemyAction = ActionStates.GMODE;
            }
            if (GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>() == null)
            {
                Debug.Log("Cannot find enemy manager!");
            }
            //check enemy action
            //   Debug.Log("Condition if Enemy." + currentEnemyAction.ToString() + " == Player." + blockMeta.condition.ToString());
            if (currentEnemyAction == blockMeta.condition)
            {
                //     Debug.Log("Condition Returned TRUE!");
                // CodeReaderID++;
                // CodeReaders.Add(CodeReaderID);
                // GetPlayerMoveCount(FindContentWithTag(block, "truecontent"));
                // StartCoroutine(ContainerReader(FindContentWithTag(block, "truecontent")));

                return(ActionStates.NULL);
            }
            else
            {
                //    Debug.Log("Condition Returned FALSE!");
                //CodeReaderID++;
                //CodeReaders.Add(CodeReaderID);
                // GetPlayerMoveCount(FindContentWithTag(block, "falsecontent"));
                //StartCoroutine(ContainerReader(FindContentWithTag(block, "falsecontent")));
                return(ActionStates.NULL);
            }
        }
        if (blockMeta.type == "repeat")
        {
            //    Debug.Log("Repeat Function Executed!");
            bool RepStep = blockMeta.RepeatStep();
            if (RepStep)
            {
                //      Debug.Log("Repeat Function Ended!");
                blockMeta.RevertRepeat();
                return(ActionStates.NULL);
            }
            else
            {
                //     Debug.Log("Repeat Function Repeated!");CodeReaderID++;
                //  CodeReaderID++;
                // CodeReaders.Add(CodeReaderID);
                //GetPlayerMoveCount(FindContentWithTag(block, "content"));
                // StartCoroutine(ContainerReader(FindContentWithTag(block, "content")));
                return(ActionStates.SPECIAL);
            }
        }
        return(ActionStates.NULL);
    }
コード例 #24
0
ファイル: Buffalo.cs プロジェクト: colincapurso/IC2013
 void ChargePlayer()
 {
     if (TargetPerson.State != Player.PlayerStates.KnockBack)
       {
     ActionState = ActionStates.Charging;
     TargetPosition = TargetPerson.Position;
     LastCharge = Game1.CurrentTime;
     Velocity.X = SPEED_CHARGE * Math.Sign(TargetPosition.X - Position.X);
     Audio.Play(SFX.AngryMoo);
       }
 }
コード例 #25
0
    //DON'T MESS AROUND THIS CURRENT CODE:  LAST MODIFIED DECEMBER 23, 2017 3:37 AM - IHG
    //THE GOLDEN RECURSIVE FUNCTION THAT READS BLOCKS
    IEnumerator CodeReader(Transform content, int depth)
    {
        Debug.Log("Starting Code Reader: " + depth);
        if (depth == 0)
        {
            blockUsed.Clear();
            pointerObj.gameObject.SetActive(true);
        }
        // int ReaderID = CodeReaderID;
        // Debug.Log("Started a Code Reader" + ReaderID);
        Transform block = content.GetChild(0);

        // pointerObj.gameObject.SetActive(true);
        blockpos = block;
        ActionStates action;
        Transform    currentBlock = block;

        while (currentBlock != null)
        {
            action = ActionStates.NULL;

            if (currentBlock.childCount == 0)
            {
                blockpos = currentBlock;
            }
            else
            {
                blockpos = currentBlock.GetChild(0);
            }

            CodeBlockMeta blockMeta = null;
            blockMeta = currentBlock.GetComponent <CodeBlockMeta>();

            //  Debug.Log("BlockMeta:" + block.name);

            if (blockMeta == null)
            {
                action = ActionStates.NULL;

                //   Debug.Log("blockMeta is null: " + currentBlock.name);
            }
            else if (blockMeta.type == "codeblock")
            {
                if (!blockUsed.Contains(currentBlock))
                {
                    blockUsed.Add(currentBlock);
                }
                //Debug.Log("Executing Function:" + blockMeta.act);
                action = blockMeta.act;
            }
            else if (blockMeta.type == "decision")
            {
                if (!blockUsed.Contains(currentBlock))
                {
                    blockUsed.Add(currentBlock);
                }
                if (GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>().actions.Count > PlayerActions.Count)
                {
                    currentEnemyAction = GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>().actions[PlayerActions.Count].Action;
                }
                else
                {
                    currentEnemyAction = ActionStates.GMODE;
                }
                if (GameObject.FindGameObjectWithTag("EM").GetComponent <ActionsScript>() == null)
                {
                    //    Debug.Log("Cannot find enemy manager!");

                    blockpos = blockMeta.transform.GetChild(0);
                }
                yield return(new WaitForSeconds(Delay));

                //check enemy action
                //   Debug.Log("Condition if Enemy." + currentEnemyAction.ToString() + " == Player." + blockMeta.condition.ToString());
                if (currentEnemyAction == blockMeta.condition)
                {
                    //     Debug.Log("Condition Returned TRUE!");
                    //CodeReaderID++;
                    //CodeReaders.Add(CodeReaderID);
                    //CodeContainerReader(FindContentWithTag(block, "truecontent"));
                    blockpos = blockMeta.transform.GetChild(0);
                    yield return(new WaitForSeconds(Delay));

                    yield return(StartCoroutine(CodeReader(FindContentWithTag(currentBlock, "truecontent"), depth + 1)));

                    action = ActionStates.NULL;
                }
                else
                {
                    blockpos = blockMeta.transform.GetChild(2);
                    yield return(new WaitForSeconds(Delay));

                    //    Debug.Log("Condition Returned FALSE!");
                    //CodeReaderID++;
                    //CodeReaders.Add(CodeReaderID);
                    //CodeContainerReader(FindContentWithTag(block, "falsecontent"));
                    yield return(StartCoroutine(CodeReader(FindContentWithTag(currentBlock, "falsecontent"), depth + 1)));

                    action = ActionStates.NULL;
                }
            }
            else if (blockMeta.type == "repeat")
            {
                if (!blockUsed.Contains(currentBlock))
                {
                    blockUsed.Add(currentBlock);
                }

                //    Debug.Log("Repeat Function Executed!");
                bool RepStep = blockMeta.RepeatStep();
                if (RepStep)
                {
                    blockpos = blockMeta.transform.GetChild(2);
                    yield return(new WaitForSeconds(Delay));

                    //      Debug.Log("Repeat Function Ended!");
                    blockMeta.RevertRepeat();
                    action = ActionStates.NULL;
                }
                else
                {
                    //     Debug.Log("Repeat Function Repeated!");CodeReaderID++;
                    //CodeReaderID++;
                    //CodeReaders.Add(CodeReaderID);
                    //  CodeContainerReader(FindContentWithTag(block, "content"));
                    blockpos = blockMeta.transform.GetChild(0);
                    yield return(new WaitForSeconds(Delay));

                    yield return(StartCoroutine(CodeReader(FindContentWithTag(currentBlock, "content"), depth + 1)));

                    action = ActionStates.SPECIAL;
                }
            }


            if (action != ActionStates.NULL && action != ActionStates.SPECIAL)
            {
                PlayerActions.Add(action);
            }
            if (action != ActionStates.SPECIAL)
            {
                currentBlock = GetNext(currentBlock);
            }


            fillPlayerActions.UpdateCanvas();
            yield return(new WaitForSeconds(Delay));
        }

        //  yield return null;
        //SimulationEnd = true;
        if (depth == 0)
        {
            pointerObj.gameObject.SetActive(false);
            SimulationEnd = true;
            fillPlayerActions.UpdateCanvas();
        }


        Debug.Log("Ending Code Reader: " + depth);

        yield return(null);

        //Debug.Log("Ended a Code Reader" + ReaderID);
        // CodeReaderID++;
    }
コード例 #26
0
ファイル: Buffalo.cs プロジェクト: colincapurso/IC2013
 void ChasePlayer()
 {
     ActionState = ActionStates.ChasingPlayer;
       GoAggressive();
       TargetPosition = TargetPerson.Position;
 }
コード例 #27
0
ファイル: Buffalo.cs プロジェクト: colincapurso/IC2013
        void GoNeutral()
        {
            BehaviourState = BehaviourStates.Neutral;

              if (ActionState != ActionStates.Standing)
            ActionState = ActionStates.Standing;
        }
コード例 #28
0
ファイル: Buffalo.cs プロジェクト: colincapurso/IC2013
 void StartPreCharge()
 {
     ActionState = ActionStates.PreCharge;
       PreChargeStart = Game1.CurrentTime;
 }
コード例 #29
0
 /// <summary>
 /// Moves dragon from old position to the new one.
 /// </summary>
 /// <param name="newPosition">new position</param>
 public void ChangePosition(Vector3 newPosition)
 {
     ActionState = ActionStates.Fly;
     Position    = Vector3.Lerp(_position, newPosition, Speed * 4 * Time.deltaTime); // 2 times faster for mobile :) sorry for magic number. it's just for beauty'
 }
コード例 #30
0
    IEnumerator simulation(int totalCount)
    {
        bool EndFight = false;

        //fillPlayerActions.UpdateCanvas();
        yield return(new WaitForSeconds(.5f));

        PlayerPointerObject.gameObject.SetActive(true);
        EnemyPointerObject.gameObject.SetActive(true);
        Debug.Log("Going to fight!");
        battlecount = 0;
        while (!bossStats.IsDead() || !playerStats.IsDead())
        {
            battlecount++;
            Debug.Log("Combat sequence:" + battlecount);
            for (int i = 0; i < totalCount; i++)
            {
                playerCurrentAction = CBM.PlayerActions[i];
                enemyCurrentAction  = EnemyActions[i];

                if (EnemyScriptCase.childCount >= i + 1)
                {
                    EnemyBlockPos = EnemyScriptCase.GetChild(i);
                }

                if (PlayerScriptCase.childCount >= i + 1)
                {
                    PlayerBlockPos = PlayerScriptCase.GetChild(i);
                }


                yield return(new WaitForSeconds(.5f));

                Debug.Log("EAS:" + enemyCurrentAction.ToString());
                EAS.ExecuteAction(enemyCurrentAction);
                PAS.ExecuteAction(playerCurrentAction);
                Rules();
                if (bossStats.IsDead() || playerStats.IsDead())
                {
                    EndFight = true;
                }


                yield return(new WaitForSeconds(3f));

                if (EndFight)
                {
                    break;
                }



                //check here if someone is dead
            }
            if (EndFight)
            {
                break;
            }
            if (/*(bossStats.currentHealth == playerStats.currentHealth) || */ (bossStats.currentHealth == bossStats.maxHealth && playerStats.currentHealth == playerStats.maxHealth))
            {
                Modal.ShowOk("The combat is concluding to a tie. Reasses your code blocks!", () => StopAll(), "Oops!");
                DebugMode();
                break;
            }
            yield return(new WaitForSeconds(.05f));
        }
        Debug.Log("end fight!");

        ////check here if player and enemy life is equal if yes declare a tie
        ////if life is not equal repeat sequence
        //AddtoConsole("Player:" + PlayerPoints + " points");
        //AddtoConsole("Enemy:" + EnemyPoints + " points");
        //Debug.Log("Player:" + PlayerPoints + " points");
        //Debug.Log("Enemy:" + EnemyPoints + " points");
        //if (PlayerPoints > EnemyPoints)
        //{
        //    Debug.Log("PLAYER WINS!");
        //    AddtoConsole("Player wins!");
        //}
        //else if (PlayerPoints < EnemyPoints)
        //{
        //    DebugMode();
        //    Debug.Log("ENEMY WINS!");
        //    AddtoConsole("Enemy Wins!");
        //}
        //else
        //{
        //    DebugMode();
        //    AddtoConsole("Its a tie");
        //    }
        AddtoConsole("End of Simulation");

        PlayerPointerObject.gameObject.SetActive(false);
        EnemyPointerObject.gameObject.SetActive(false);
        IsCompiling  = false;
        IsSimulating = false;

        yield return(new WaitForSeconds(7f));

        if (bossStats.IsDead())
        {
            Debug.Log("Used " + CBM.blockUsed.Count + " blocks");
            WinSum.blockUsed = CBM.blockUsed.Count;
            WinSum.IsPerfect = (playerStats.currentHealth >= playerStats.maxHealth);
            WinSum.ShowWin();
        }
    }