Esempio n. 1
0
File: Level.cs Progetto: huot14/LD43
    //public int playerState = (int) PlayerState.stationary;

    public void Start()
    {
        Level.instance       = this;
        this.total_prisoners = this.prisoners.Length;

        Debug.Log("Start is " + start.name);
        Debug.Log("End is " + end.name);
        Debug.Log("Score is " + this.score);

        this.current = start;
        createMovementHints();

        nearbyTraps = NearbyTraps.count(1, this.current);


        /* Create the player located at start */
    }
Esempio n. 2
0
File: Level.cs Progetto: huot14/LD43
    IEnumerator Teleport(GameObject objectToMove, Vector3 end, Tile to)
    {
        if (SoundManager.instance != null)
        {
            SoundManager.instance.playEffect(SoundManager.SoundEffect.TELEPORT);
        }

        while (objectToMove.transform.position != end)
        {
            // TODO: Create teleporting effect
            objectToMove.transform.position = end;
            yield return(new WaitForEndOfFrame());
        }

        playerState = PlayerState.STATIONARY;
        createMovementHints();
        /*Update trap counter*/
        this.nearbyTraps = NearbyTraps.count(1, to);
    }
Esempio n. 3
0
File: Level.cs Progetto: huot14/LD43
    IEnumerator MoveWithSpeed(GameObject objectToMove, Vector3 end, float speed, Tile _from, Tile to)
    {
        while (objectToMove.transform.position != end)
        {
            objectToMove.transform.LookAt(end);
            objectToMove.transform.position = Vector3.MoveTowards(objectToMove.transform.position, end, speed * Time.deltaTime);
            yield return(new WaitForEndOfFrame());
        }
        playerState = PlayerState.STATIONARY;
        createMovementHints();

        // Check if we have arrived at a teleporter, automatically teleport to the connected tile
        var teleporter = to.GetComponent <Teleporter>();

        if (teleporter != null)
        {
            Tile dest = teleporter.destination();
            playerState = PlayerState.TELEPORTING;
            movePlayer(dest);
        }

        /*Trigger Traps!*/
        var traps = to.GetComponents <Trap>();

        foreach (var trap in traps)
        {
            if (!trap.activated())
            {
                trap.activate();
                this.killPrisoner();
                markTrap(to);
            }
        }
        nearbyTraps = NearbyTraps.count(1, to);


        // END OF LEVEL(WIN)
        if (this.current == this.end)
        {
            endLevelUI.activateEndUI();
            endLevelUI.levelOver(true, score);
            playerState = PlayerState.MOVING;
        }

        /*Color Transition Logic*/
        var maybeToColor      = to.GetComponent <TileColor> ();
        var maybeToTransition = to.GetComponent <TileTransition> ();

        var maybeFromColor      = _from.GetComponent <TileColor> ();
        var maybeFromTransition = _from.GetComponent <TileTransition>();

        if (maybeToTransition != null)
        {
            var toTransition = maybeToTransition;
            if (maybeFromColor != null)
            {
                var  fromColor = maybeFromColor;
                bool allowed   = toTransition.isAllowed(fromColor.color);
                if (!allowed)
                {
                    this.killPrisoner();
                }
            }
        }
        else if (maybeFromTransition != null)
        {
            var fromTransition = maybeFromTransition;
            if (maybeToColor != null)
            {
                var  toColor = maybeToColor;
                bool allowed = fromTransition.isAllowed(toColor.color);
                if (!allowed)
                {
                    this.killPrisoner();
                }
            }
        }
        else if (maybeFromColor != null && maybeToColor != null)
        {
            if (maybeFromColor.color.color != maybeToColor.color.color)
            {
                this.killPrisoner();
            }
        }
    }