Пример #1
0
 // Use this for initialization
 void Start()
 {
     hero       = GameObject.FindGameObjectWithTag(BSConstants.TAG_HERO).GetComponent <Hero>();
     terrainGen = GameObject.FindGameObjectWithTag(BSConstants.TAG_GAME_CONTROLLER).GetComponent <TerrainGen>();
     //v3MatrixPosition = this.transform.position = new Vector3(Random.Range(0,BSConstants.X_SIZE), 0, Random.Range(0, BSConstants.Z_SIZE));
     //transform.position = new Vector3(transform.position.x, BSConstants.POSITION_OVER_SCENARIO_Y, transform.position.z);
     if (bOnTop)
     {
         transform.SetParent(terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().goTopTile.transform);
     }
     else
     {
         transform.SetParent(terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().goBotTile.transform);
     }
 }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        terrainGen       = GameObject.FindGameObjectWithTag(BSConstants.TAG_GAME_CONTROLLER).GetComponent <TerrainGen>();
        v3MatrixPosition = transform.position = new Vector3(terrainGen.v2EntrancePosition.x, 0, terrainGen.v2EntrancePosition.y);

        transform.position = new Vector3(transform.position.x, BSConstants.POSITION_OVER_SCENARIO_Y, transform.position.z);

        v3FacingDirection = Vector3.right;
        Vector3 v3Rot;

        v3Rot = new Vector3(0, 180, 0);
        transform.rotation = Quaternion.Euler(v3Rot);

        transform.SetParent(terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().goTopTile.transform);
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponent <Tile>().GetTileTypeFrom(bOnTop) == BSEnums.TileType.TRAP)
        {
            Die();
        }
        if (bOnTop == hero.bOnTop &&
            terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponent <Tile>().bFinishedRotating &&
            Time.realtimeSinceStartup >= fLastTimeMovement + DELAY_BETWEEN_INPUTS)
        {
            fLastTimeMovement = Time.realtimeSinceStartup;
            Vector3 v3Nextstep = GetNextStep();
            Vector3 v3Rot;
            if (v3Nextstep == Vector3.right)
            {
                v3Rot = new Vector3(0, 180, 0);
            }
            else if (v3Nextstep == Vector3.left)
            {
                v3Rot = new Vector3(0, 0, 0);
            }
            else if (v3Nextstep == Vector3.back)
            {
                v3Rot = new Vector3(0, 270, 0);
            }
            else
            {
                v3Rot = new Vector3(0, 90, 0);
            }
            transform.parent    = null;
            transform.rotation  = Quaternion.Euler(v3Rot);
            transform.position += v3Nextstep;
            v3MatrixPosition   += v3Nextstep;

            if (bOnTop)
            {
                if (terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().bOnTop)
                {
                    transform.SetParent(terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().goTopTile.transform);
                }
                else
                {
                    transform.SetParent(terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().goBotTile.transform);
                }
            }
            else
            {
                if (terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().bOnTop)
                {
                    transform.SetParent(terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().goBotTile.transform);
                }
                else
                {
                    transform.SetParent(terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponentInChildren <Tile>().goTopTile.transform);
                }
            }
        }
        else if (bOnTop != hero.bOnTop)
        {
            fLastTimeMovement = Time.realtimeSinceStartup;
        }
    }
Пример #4
0
    private void InputController()
    {
        if ((BSUtils.WorldPosToMatrix(v3MatrixPosition) == terrainGen.v2ExitPositionTop &&
             terrainGen.GetTile(terrainGen.v2ExitPositionTop).GetComponent <Tile>().bOnTop == bOnTop) ||
            (BSUtils.WorldPosToMatrix(v3MatrixPosition) == terrainGen.v2ExitPositionBot &&
             terrainGen.GetTile(terrainGen.v2ExitPositionBot).GetComponent <Tile>().bOnTop != bOnTop)
            )
        {
            WonLevel();
        }
        else if (terrainGen.GetTile(BSUtils.WorldPosToMatrix(v3MatrixPosition)).GetComponent <Tile>().GetTileTypeFrom(bOnTop) == BSEnums.TileType.TRAP)
        {
            Die();
        }

        if (iMana > BSConstants.SPELL_COST)
        {
            if (Time.realtimeSinceStartup >= fLastTimeSwap + SWAP_COOLDOWN)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    fLastTimeSwap = Time.realtimeSinceStartup;
                    SwapTile();
                }
            }


            if (Time.realtimeSinceStartup >= fLastTimeMovement + DELAY_BETWEEN_INPUTS /*&& terrainGen.GetTile(v3MatrixPosition).GetComponentInChildren<Tile>().bFinishedRotating*/)
            {
                if (Input.GetAxisRaw("Vertical") > 0)
                {
                    MoveInDirection(Vector3.forward);
                }
                else if (Input.GetAxisRaw("Vertical") < 0)
                {
                    MoveInDirection(Vector3.back);
                }
                else if (Input.GetAxisRaw("Horizontal") > 0)
                {
                    MoveInDirection(Vector3.right);
                }
                else if (Input.GetAxisRaw("Horizontal") < 0)
                {
                    MoveInDirection(Vector3.left);
                }
            }
        }
    }