Esempio n. 1
0
    //攻撃処理
    public void Attack(MapPresenter m, Dictionary <int, CharacterPresenter> characterListPresenter)
    {
        Vector3 pos = status.position + status.direction;

        if (pos.x < 0 || pos.z < 0)
        {
            return;
        }

        var vector2Int = new Vector2Int((int)pos.x, (int)pos.z);

        if (m.GetTileModel(vector2Int).charaType == TileModel.CharaType.Player ||
            m.GetTileModel(vector2Int).charaType == TileModel.CharaType.Enemy)
        {
            CharacterPresenter characterPresenter =
                characterListPresenter
                .FirstOrDefault(presenter => presenter.Key == m.GetTileModel(vector2Int).guid).Value;

            int damage = CalcAction.CalcAttack(status, characterPresenter.status);

            Debug.Log("Attack Damage : " + damage);
            characterPresenter.CalcHp(damage);
            Debug.Log("After Hp : " + characterPresenter.status.hp);

            ActionLogPresenter.Instance.ShowView();
            ActionLogPresenter.Instance.AddLog(LogType.Attack, new string[] { status.name, characterPresenter.status.name, damage.ToString() });
            if (characterPresenter.status.hp <= 0)
            {
                characterPresenter.Death();
            }
        }
        SetIsAction(true);

        characterView.Attack();
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        m_fsm = new FSM();
        FSMState  state1  = new FSMState("log", m_fsm, true);
        LogAction action1 = new LogAction();

        action1.SetOwner(state1);
        state1.AddAction(action1);
        state1.AddTransition("calc", 2);

        FSMState   state2  = new FSMState("calc", m_fsm);
        CalcAction action2 = new CalcAction();

        action2.SetOwner(state2);
        state2.AddAction(action2);
        state2.AddTransition("log", state1.id);

        m_fsm.AddTransition("g_calc", state2.id);
        m_fsm.AddTransition("g_log", state1.id);

        m_fsm.AddState(state1);
        m_fsm.AddState(state2);

        m_fsm.Initialize();
        m_fsm.EnableFSM();

        StartCoroutine(SendGlobalEvent());
    }
 public void Multiply(int value)
 {
     CalcAction act = new CalcAction()
     {
         operation = Multiply,
         actionTotal = total * value,
         actionValue = value
     };
     total = act.actionTotal;
     stack.Push(act);
     undoAction = false;
 }
 public void Subtract(int value)
 {
     CalcAction act = new CalcAction()
     {
         operation = Subtract,
         actionTotal = total - value,
         actionValue = value
     };
     total = act.actionTotal;
     stack.Push(act);
     undoAction = false;
 }
 public void Add(int value)
 {
     CalcAction act = new CalcAction() 
     { 
         operation = Add, 
         actionTotal = total + value, 
         actionValue = value 
     };
     total = act.actionTotal;
     stack.Push(act);
     undoAction = false;
 }
 public void RepeatLastCommand()
 {
     if (stack.Count > 0)
     {
         if(undoAction)
             Undo();
         else
         {
             CalcAction act = stack.Peek();
             act.operation(act.actionValue);
         }
     }
 }
        public void ExampleTestB(Calculator calc, int valA, int valB, CalcAction action)
        {
            switch (action)
            {
            case CalcAction.Add:
                Assert.AreEqual(calc.Add(valA, valB), valA + valB);
                break;

            case CalcAction.Divide:
                Assert.AreEqual(calc.Add(valA, valB), valA / valB);
                break;

            case CalcAction.Multiply:
                Assert.AreEqual(calc.Add(valA, valB), valA * valB);
                break;

            case CalcAction.Subtract:
                Assert.AreEqual(calc.Add(valA, valB), valA - valB);
                break;
            }
        }