示例#1
0
    public void SpeakToPeople()
    {
        IInteractiveObject otherObject = null;

        MapGenerator.Coord myPosition = MapGenerator.ConvertWorldToIndex(transform.position);

        switch (currentDirection)
        {
        case direction.up:
            otherObject = GetInteractiveObject(myPosition.i, myPosition.j - 1);
            break;

        case direction.down:
            otherObject = GetInteractiveObject(myPosition.i, myPosition.j + 1);
            break;

        case direction.left:
            otherObject = GetInteractiveObject(myPosition.i - 1, myPosition.j);
            break;

        case direction.right:
            otherObject = GetInteractiveObject(myPosition.i + 1, myPosition.j);
            break;
        }
        if (otherObject != null && Input.GetKey(KeyCode.Space))
        {
            otherObject.StartInteraction();
        }
    }
示例#2
0
    internal void Interact(Vector3 pos)
    {
        int i = (int)pos.x;
        int j = (int)pos.y;

        if (i < 1 || j < 1 || i > 9 || j > 9)
        {
            return;
        }
        IInteractiveObject obj = mapsInterctac[i, j];

        if (obj != null)
        {
            obj.StartInteraction();
        }
    }