コード例 #1
0
ファイル: Role.cs プロジェクト: yishengabcd/BattleMode
    protected virtual void Die()
    {
        CancelAllActionsAndCommands();
        IAction dieAct = new DieAction(this);

        AddAction(dieAct);
    }
コード例 #2
0
    void Start()
    {
        attack = DataManager.Instance.weaponattack;
        hp     = DataManager.Instance.bodyhp;
        amor   = DataManager.Instance.legamor + DataManager.Instance.bodyamor;
        speed  = DataManager.Instance.legspeed;
        lange  = DataManager.Instance.weaponlange;
        //다리 정보 찾아서 생성
        for (int i = 0; i < DataManager.Instance.legPartsArr.Length; i++)
        {
            if (DataManager.Instance.legPartsArr[i].name == legname)
            {
                legObj = Instantiate(DataManager.Instance.legPartsArr[i], transform.position, Quaternion.identity, transform);
            }
        }
        //몸체 정보 찾아서 생성
        for (int i = 0; i < DataManager.Instance.bodyPartsArr.Length; i++)
        {
            if (DataManager.Instance.bodyPartsArr[i].name == bodyname)
            {
                bodyObj = Instantiate(DataManager.Instance.bodyPartsArr[i], legObj.GetComponent <LegParts>().bodyPos.transform.position, Quaternion.identity, transform);
            }
        }
        //무기 정보 찾아서 생성
        for (int i = 0; i < DataManager.Instance.weaponPartsArr.Length; i++)
        {
            if (DataManager.Instance.weaponPartsArr[i].name == weaponname)
            {
                weaponObj = Instantiate(DataManager.Instance.weaponPartsArr[i], bodyObj.GetComponent <BodyParts>().weaponPos.transform.position, Quaternion.identity, transform);
            }
        }
        transform.forward = PhotonManager.Instance.hostingResultList[0].Result.Anchor.transform.position - transform.position;
        if (actnum == PhotonManager.Instance.myOrder)
        {
            isMine.SetActive(true);
        }
        barrel = weaponObj.GetComponent <WeaponParts>().ReturnTransform();

        legObj.GetComponent <LegParts>().OnDepthMateiral();
        bodyObj.GetComponent <BodyParts>().OnDepthMateiral();
        weaponObj.GetComponent <WeaponParts>().OnDepthMateiral();
        //죽엇을때 모습을위함 메소드가 들어 있음
        bodyAction   = bodyObj.GetComponent <DieAction>();
        weaponAction = weaponObj.GetComponent <DieAction>();

        if (PhotonManager.Instance.myOrder == actnum)
        {
            PhotonManager.Instance.myHp   = hp;
            PhotonManager.Instance.myAmor = amor;
            PhotonManager.Instance.myDmg  = attack;
            DataManager.Instance.ResetmyTime();
            DataManager.Instance.GameStart(true);//내로봇이 생성되면 게임이 사작된것이다
            //if(PhotonManager.Instance.isMaster==true)
            //{
            //    DataManager.Instance.ChangeControlable(true);
            //}
        }
    }
コード例 #3
0
    IEnumerator InitActions()
    {
        yield return(new WaitForSeconds(0.01f));

        IdleInitAction = new IdleAction(this, "Idle", NV, mr, colliders, Ani);
        AttackAction   = new NormalAttack(this, new string[] { "劈砍1", "劈砍3" }, 0.44f, NV, Ani);
        BackAction     = new TakeBack(this, "", NV, transform);
        InjuredAction  = new InjuredAction(this, "GetHit", 1, NV, Ani);
        RunAction      = new RunAction(this, "Run", NV, Ani);
        DieAction      = new DieAction(this, "Die", mr, NV, transform, colliders, Ani, 0.2f);
    }
コード例 #4
0
ファイル: CharacterStats.cs プロジェクト: bjaajb11/Robots
 public void TakeDamage(int damage)
 {
     _currentHealth -= damage;
     if (damage > 0)
     {
         TakeDamageAction?.Invoke(damage);
     }
     if (_currentHealth <= 0)
     {
         DieAction?.Invoke();
     }
 }
コード例 #5
0
ファイル: LineSoliderAI.cs プロジェクト: GameObjectW/AINew
 public override void Awake()
 {
     base.Awake();
     IdleInitAction = new IdleAction(this, "Idle", NV, mr, colliders, Ani);
     AttackAction   = new NormalAttack(this, new string[] { "attack1", "attack2" }, 0.44f, NV, Ani);
     BackAction     = new TakeBack(this, "", NV, transform);
     InjuredAction  = new InjuredAction(this, "GetHit", 1, NV, Ani);
     RunAction      = new RunAction(this, "Run", NV, Ani);
     DieAction      = new DieAction(this, "Die", mr, NV, transform, colliders, Ani, 0.2f);
     //技能节点初始化(skill1Action是AI中需要cd和weight控制的技能,而skill1Action是根据相应的触发条件触发的)
     skill1Action = new SYSkillAction(this, "skill1", 0.7f, 0.7f, NV, 10, Ani);
     skill2Action = new JumpAction(this, "skill2", 1.4f, 3f, NV, 3, Ani, 1.65f);
     //将通过冷却和权值的技能添加到总技能列表中(所以仅将skill1Action进行CD和Weight的封装并添加,而skill2Action在update中根据条件来单独控制技能的触发)
     SkillList.Add(new SkillCDAndWeight_New(skill1Action, 10, 20));
 }
コード例 #6
0
        private void BuildDieState(State inTargetState, NpcController inNpcController, NpcDataHolder inNpcData)
        {
            // --------------------------------------------------------------------------------
            // 1-  Setup Actions
            // --------------------------------------------------------------------------------
            var dieAction = new DieAction(inNpcController);

            // --------------------------------------------------------------------------------
            // 2-  Define State
            // --------------------------------------------------------------------------------
            inTargetState.Define(
                Color.green, new Action[] { dieAction },
                null
                );
        }
コード例 #7
0
ファイル: EntityBrain.cs プロジェクト: towa-hi/Block-Game
    public override ActionResult GetActionResult(BoardState aBoardState)
    {
        Debug.Log(this.id + " DieAction.GetActionResult");
        BoardState simBoardState = aBoardState;

        switch (GetFightResult(aBoardState, this.id, this.attackerId, this.deathType))
        {
        case FightResultEnum.DEFENDER_DIES:
            Debug.Log(this.id + " DieAction.GetActionResult defender dies");
            return(new ActionResult(this, ApplyAction(simBoardState)));

        case FightResultEnum.ATTACKER_DIES:
            Debug.Log(this.id + " DieAction.GetActionResult attacker dies");
            DieAction attackerDieAction = new DieAction(this.attackerId, this.id, GetReciprocalDeathType());
            return(new ActionResult(attackerDieAction, attackerDieAction.ApplyAction(simBoardState)));

        case FightResultEnum.TIE:
            Debug.Log(this.id + " DieAction.GetActionResult tie");
            return(new ActionResult(this, null));

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
コード例 #8
0
ファイル: EntityBrain.cs プロジェクト: towa-hi/Block-Game
    public override ActionResult GetActionResult(BoardState aBoardState)
    {
        Debug.Log(this.id + " MoveAction.GetActionResult");
        BoardState  simBoardState  = aBoardState;
        EntityState simEntityState = simBoardState.GetEntityById(this.id);
        Vector2Int  startPos       = simEntityState.pos;
        Vector2Int  endPos         = startPos + this.direction;

        if (!simEntityState.mobData.HasValue)
        {
            Debug.Log(this.id + " MoveAction.GetActionResult is not a mob RETURNING");
            return(new ActionResult(this, null));
        }
        if (!simBoardState.DoesFloorExist(endPos, simEntityState.id))
        {
            Debug.Log(this.id + " MoveAction.GetActionResult couldnt find floor (pre-sweep) RETURNING");
            return(new ActionResult(this, null));
        }
        Dictionary <Vector2Int, BoardCell> affectedBoardSlice = simBoardState.GetBoardCellSlice(endPos, simEntityState.size);
        // getting a list of entities inside the new position
        HashSet <int> affectedEntityIdSet = new HashSet <int>();

        foreach (BoardCell affectedBoardCell in affectedBoardSlice.Values)
        {
            int?affectedEntityId = affectedBoardCell.GetEntityId(simEntityState.isFront);
            if (affectedEntityId.HasValue && affectedEntityId.Value != simEntityState.id)
            {
                affectedEntityIdSet.Add(affectedEntityId.Value);
            }
        }
        ActionResult?       deathActionResult        = null;
        List <ActionResult> requiredActionResultList = new List <ActionResult>();

        // for each entity thats gonna get affected by this action
        foreach (int affectedEntityId in affectedEntityIdSet)
        {
            // flag thats true if all entities i encounter can be moved out of the way somehow
            bool foundValidActionForAffectedEntity = false;
            foreach (EntityActionEnum requiredActionEnum in this.priorityList)
            {
                EntityAction requiredAction;
                // for each possible action that nextEntity can perform
                switch (requiredActionEnum)
                {
                case EntityActionEnum.MOVE:
                    throw new NotImplementedException();

                case EntityActionEnum.FALL:
                    throw new NotImplementedException();

                case EntityActionEnum.DIE:
                    requiredAction = new DieAction(affectedEntityId, simEntityState.id, DeathTypeEnum.BUMP);
                    break;

                case EntityActionEnum.PUSH:
                    Vector2Int pushDirection = new Vector2Int(this.direction.x, 0);
                    requiredAction = new PushAction(affectedEntityId, simEntityState.id, pushDirection);
                    break;

                case EntityActionEnum.TURN:
                    throw new NotImplementedException();

                case EntityActionEnum.WAIT:
                    throw new NotImplementedException();

                default:
                    throw new ArgumentOutOfRangeException();
                }
                // simulate that action and get result
                Debug.Log(this.id + " --- UP STACK to " + affectedEntityId + "---");
                ActionResult requiredActionResult = requiredAction.GetActionResult(simBoardState);
                Debug.Log(this.id + " --- DOWN STACK from " + affectedEntityId + " ---");
                // if nextAction was valid
                if (requiredActionResult.boardState.HasValue)
                {
                    simBoardState = requiredActionResult.boardState.Value;
                    // if the action is one perscribed for me by the thing i encountered
                    if (requiredActionResult.entityAction.id == this.id)
                    {
                        if (requiredActionResult.entityAction.entityActionEnum == EntityActionEnum.DIE)
                        {
                            deathActionResult = requiredActionResult;
                        }
                    }
                    else
                    {
                        Debug.Assert(requiredActionResult.entityAction.id == affectedEntityId);
                        requiredActionResultList.Add(requiredActionResult);
                    }
                    foundValidActionForAffectedEntity = true;
                }
                else
                {
                    Debug.Log(this.id + " MoveAction.GetActionResult failed to do " + requiredAction.GetType() + " on " + affectedEntityId);
                }
            }
            if (!foundValidActionForAffectedEntity)
            {
                Debug.Log(this.id + " MoveAction.GetActionResult exhausted possible actions on " + affectedEntityId + " RETURNING");
                return(new ActionResult(this, null));
            }
            if (deathActionResult.HasValue)
            {
                requiredActionResultList.Clear();
                Debug.Log(this.id + " MoveAction.GetActionResult had only one viable move causing self-death");
                return(deathActionResult.Value);
            }
        }
        // another floor check
        if (!simBoardState.DoesFloorExist(endPos, simEntityState.id))
        {
            Debug.Log(this.id + " MoveAction.GetActionResult couldnt find floor (post-sweep) RETURNING");
            return(new ActionResult(this, null));
        }
        simBoardState = ApplyAction(simBoardState);
        Debug.Log(this.id + " MoveAction.GetActionResult returned a valid result RETURNING");
        return(new ActionResult(this, simBoardState, requiredActionResultList));
    }
コード例 #9
0
ファイル: EntityBrain.cs プロジェクト: towa-hi/Block-Game
    public override ActionResult GetActionResult(BoardState aBoardState)
    {
        // Debug.Log(this.id + " FallAction.GetActionResult");
        BoardState  simBoardState  = aBoardState;
        EntityState simEntityState = simBoardState.GetEntityById(this.id);
        Vector2Int  startPos       = simEntityState.pos;
        Vector2Int  endPos         = startPos + this.direction;

        if (!simEntityState.mobData.HasValue)
        {
            // Debug.Log(this.id + " FallAction.ApplyAction done on non-mob entity RETURNING");
            return(new ActionResult(this, null));
        }
        if (!simEntityState.mobData.Value.canFall)
        {
            // Debug.Log(this.id + "FallAction.ApplyAction done on non fallable entity RETURNING");
            return(new ActionResult(this, null));
        }
        Dictionary <Vector2Int, BoardCell> affectedBoardSlice = simBoardState.GetBoardCellSlice(endPos, simEntityState.size);
        // Getting a list of entities inside the new position
        HashSet <int> affectedEntityIdSet = new HashSet <int>();

        foreach (BoardCell affectedBoardCell in affectedBoardSlice.Values)
        {
            int?affectedEntityId = affectedBoardCell.GetEntityId(simEntityState.isFront);
            if (affectedEntityId.HasValue && affectedEntityId.Value != simEntityState.id)
            {
                affectedEntityIdSet.Add(affectedEntityId.Value);
            }
        }
        ActionResult?       deathActionResult        = null;
        List <ActionResult> requiredActionResultList = new List <ActionResult>();

        // for each entity thats gonna get affected by this action
        foreach (int affectedEntityId in affectedEntityIdSet)
        {
            // flag thats true if all entities i encounter can be moved out of the way somehow
            bool foundValidActionForAffectedEntity = false;
            foreach (EntityActionEnum requiredActionEnum in this.priorityList)
            {
                EntityAction requiredAction;
                // for each possible action that nextEntity can perform
                switch (requiredActionEnum)
                {
                case EntityActionEnum.MOVE:
                    throw new NotImplementedException();

                case EntityActionEnum.FALL:
                    throw new NotImplementedException();

                case EntityActionEnum.DIE:
                    requiredAction = new DieAction(affectedEntityId, simEntityState.id, DeathTypeEnum.SQUISHED);
                    break;

                case EntityActionEnum.PUSH:
                    throw new NotImplementedException();

                case EntityActionEnum.TURN:
                    throw new NotImplementedException();

                case EntityActionEnum.WAIT:
                    throw new NotImplementedException();

                default:
                    throw new NotImplementedException();
                }
                // Debug.Log("--- UP STACK to " + affectedEntityId + "---");
                ActionResult requiredActionResult = requiredAction.GetActionResult(simBoardState);
                // Debug.Log("--- DOWN STACK from " + affectedEntityId + " ---");
                if (requiredActionResult.boardState.HasValue)
                {
                    simBoardState = requiredActionResult.boardState.Value;
                    if (requiredActionResult.entityAction.id == this.id)
                    {
                        if (requiredActionResult.entityAction.entityActionEnum == EntityActionEnum.DIE)
                        {
                            deathActionResult = requiredActionResult;
                        }
                    }
                    else
                    {
                        Debug.Assert(requiredActionResult.entityAction.id == affectedEntityId);
                        requiredActionResultList.Add(requiredActionResult);
                    }
                    foundValidActionForAffectedEntity = true;
                }
                else
                {
                    // Debug.Log(this.id + " FallAction.GetActionResult failed to do " + requiredAction + " on " + affectedEntityId);
                }
            }
            if (!foundValidActionForAffectedEntity)
            {
                // Debug.Log(this.id + " FallAction.GetActionResult exhausted possible actions on " + affectedEntityId + " RETURNING");
                return(new ActionResult(this, null));
            }
            if (deathActionResult.HasValue)
            {
                // Debug.Log(this.id + " FallAction.GetActionResult had only one viable move causing self-death RETURNING");
                return(deathActionResult.Value);
            }
        }
        simBoardState = ApplyAction(simBoardState);
        // Debug.Log(this.id + " FallAction.GetActionResult returned a valid result RETURNING");
        return(new ActionResult(this, simBoardState, requiredActionResultList));
    }
コード例 #10
0
 /////////////////////////////////////////////
 public void RegisterDieAction(DieAction call)
 {
     dieAction += call;
 }