Exemple #1
0
    void OnMove(MoveInfo move, CharacterInfo player)
    {
        // Record the button that was pressed and the time it was pressed
        //Debug.Log("[" + Time.time + "] Player " + player.GetInstanceID() + " inputted " + (int)move.buttonExecution[0]);

        // New values
        Dictionary <string, string> p1Changes = new Dictionary <string, string>(),
                                    p2Changes = new Dictionary <string, string>();

        // Record move information
        if (player.GetInstanceID() == p1.GetInstanceID())
        {
            if (move.moveName != Constants.EVADE)
            {
                //bb.UpdateProperty(Constants.p1Key, Constants.lastAttackByPlayer, move.moveName);
                //bb.UpdateProperty(Constants.p2Key, Constants.lastAttackByOpponent, move.moveName);
                p1Changes.Add(Constants.lastAttackByPlayer, move.moveName);
                p2Changes.Add(Constants.lastAttackByOpponent, move.moveName);

                // This is an attack
                //bb.UpdateProperty(Constants.p1Key, Surprise.attackCount, (int.Parse(bb.GetProperties(Constants.p1Key)[Surprise.attackCount]) + 1).ToString());
                p1Changes.Add(Surprise.attackCount, (int.Parse(bb.GetProperties(Constants.p1Key)[Surprise.attackCount]) + 1).ToString());

                // Wait to see if it missed
                AttackMissed(move, player);
            }
            else
            {
                //bb.UpdateProperty(Constants.p1Key, Constants.lastEvade, Constants.TRUE);
                p1Changes.Add(Constants.lastEvade, Constants.TRUE);

                // This is an evade
                //bb.UpdateProperty(Constants.p1Key, Surprise.evadeCount, (int.Parse(bb.GetProperties(Constants.p1Key)[Surprise.evadeCount]) + 1).ToString());
                p1Changes.Add(Surprise.evadeCount, (int.Parse(bb.GetProperties(Constants.p1Key)[Surprise.evadeCount]) + 1).ToString());
            }

            // Update distance
            //bb.UpdateProperty(Constants.p1Key, Constants.distToOpponent, Vector3.Distance(UFE.GetPlayer1Controller().transform.position, UFE.GetPlayer2Controller().transform.position).ToString());
        }
        else
        {
            if (move.moveName != Constants.EVADE)
            {
                //bb.UpdateProperty(Constants.p2Key, Constants.lastAttackByPlayer, move.moveName);
                //bb.UpdateProperty(Constants.p1Key, Constants.lastAttackByOpponent, move.moveName);
                p2Changes.Add(Constants.lastAttackByPlayer, move.moveName);
                p1Changes.Add(Constants.lastAttackByOpponent, move.moveName);

                // This is an attack
                //bb.UpdateProperty(Constants.p2Key, Surprise.attackCount, (int.Parse(bb.GetProperties(Constants.p2Key)[Surprise.attackCount]) + 1).ToString());
                p2Changes.Add(Surprise.attackCount, (int.Parse(bb.GetProperties(Constants.p2Key)[Surprise.attackCount]) + 1).ToString());

                // Wait to see if it missed
                AttackMissed(move, player);
            }
            else
            {
                //bb.UpdateProperty(Constants.p2Key, Constants.lastEvade, Constants.TRUE);
                p2Changes.Add(Constants.lastEvade, Constants.TRUE);

                // This is an evade
                //bb.UpdateProperty(Constants.p2Key, Surprise.evadeCount, (int.Parse(bb.GetProperties(Constants.p2Key)[Surprise.evadeCount]) + 1).ToString());
                p2Changes.Add(Surprise.evadeCount, (int.Parse(bb.GetProperties(Constants.p2Key)[Surprise.evadeCount]) + 1).ToString());
            }

            // Update distance
            //bb.UpdateProperty(Constants.p2Key, Constants.distToOpponent, Vector3.Distance(UFE.GetPlayer1Controller().transform.position, UFE.GetPlayer2Controller().transform.position).ToString());
        }

        // Update distances
        p1Changes.Add(Constants.distToOpponent, Vector3.Distance(UFE.GetPlayer1Controller().transform.position, UFE.GetPlayer2Controller().transform.position).ToString());
        p2Changes.Add(Constants.distToOpponent, Vector3.Distance(UFE.GetPlayer1Controller().transform.position, UFE.GetPlayer2Controller().transform.position).ToString());

        // Save the state of the BlackBoard
        //Debug.Log("Saved BlackBoard state");
        bb.UpdateProperties(Constants.p1Key, p1Changes);
        bb.UpdateProperties(Constants.p2Key, p2Changes);
    }