示例#1
0
    public void AddPlayer(PlayerMB player)
    {
        // Initialize the player
        Assert.IsTrue(player != null);
        NodeMB startingNode = nodes[enterXY.x, enterXY.y];

        player.Initialize(startingNode);
    }
示例#2
0
    public void Initialize(NodeMB currentNode)
    {
        // Initialize references
        this.currentNode = currentNode;
        Assert.IsTrue(currentNode != null);

        // Initialize variables
        NumTurnsToMove     = 1;
        transform.position = currentNode.transform.position;

        Debug.Log("Initialize " + name);
    }
示例#3
0
    public virtual void Move(DirectionType direction)
    {
        // Get the node to move to
        NodeMB targetNode = currentNode.GetNextNode(direction);

        if (targetNode != null)
        {
            // Tick up counter
            numTurnsCounter++;

            if (numTurnsCounter == NumTurnsToMove)
            {
                numTurnsCounter = 0;
                currentNode     = targetNode;
                currentNode.OnEnterNode(this);
                transform.position = targetNode.transform.position;
            }
        }

        // Set facing direction
        CurrentDirection = direction;
    }
示例#4
0
    private NodeMB CreateNode(NodeType type, int x, int y)
    {
        // Instantiate node prefab
        NodeMB node = Instantiate(nodePrefab).GetComponent <NodeMB>();

        Assert.IsTrue(node != null);

        // Set the node variables
        node.type       = type;
        node.effect     = NodeEffects.GetEffect(type);
        node.NodeSprite = SpriteManagerMB.GetNodeSprite(type);

        // Set node position
        node.transform.parent   = transform;
        node.transform.position = x * Vector3.right + y * Vector3.up;

        // Add node to array
        node.x    = x;
        node.y    = y;
        node.name = "Node X " + x + " Y " + y;

        return(node);
    }
示例#5
0
 public Edge(NodeMB nodeNext, bool isNavigable)
 {
     this.nodeNext    = nodeNext;
     this.isNavigable = isNavigable;
 }