Beispiel #1
0
    void Awake()
    {
        Toolbox.Log("Snake Awake: " + GetInstanceID());
        Toolbox.Log("Snake Awake Frame: " + Time.frameCount);
        snakeEvents = new GameEvents <SnakeCompoundEvent, Snake>();
        links       = new List <SnakeTail>();
        all.Add(this);

        SnakeDieEvent.DoExecute(this);

        StartTicking();
    }
Beispiel #2
0
    public void SetSnakeData(SnakeState state)
    {
        this.head.transform.position = state.headPosition;
        this.currentDirection        = state.direction;
        this.links = state.linkPositions.Select(x => Instantiate(snakeTailPrefab, x, Quaternion.identity, this.transform).GetComponent <SnakeTail>()).ToList();

        if (state.isDead == false)
        {
            SnakeDieEvent.DoReverse(this);
        }
        else
        {
            SnakeDieEvent.DoExecute(this);
        }
    }