Exemple #1
0
    public static Vector3 FacingToVector(ObjectFacing inputFacing)
    {
        Debug.Log("Facing: " + inputFacing);
        Vector3 output = Vector3.zero;

        switch (inputFacing)
        {
        case ObjectFacing.North:
            output = Vector3.forward;
            break;

        case ObjectFacing.South:
            output = Vector3.back;
            break;

        case ObjectFacing.East:
            output = Vector3.right;
            break;

        case ObjectFacing.West:
            output = Vector3.left;
            break;
        }

        return(output);
    }
Exemple #2
0
    void ObjectPostConfig(GameObject target, ObjectFacing inputFacing)
    {
        MapObjectData tempData = target.GetComponent <MapObjectData> ();

        switch (tempData.type)
        {
        case ObjectType.Player:
            // add to list
            MainGameManager._Instance.PlayerList.Add(target);
            break;

        case ObjectType.Enemy:
            // add to list
            MainGameManager._Instance.enemyList.Add(target);
            break;

        case ObjectType.Wall:
            // add to list
            MainGameManager._Instance.wallList.Add(target);
            break;

        case ObjectType.DirectionalMove:
            target.GetComponent <ObjectMovement> ().facingConfig = inputFacing;
            MainGameManager._Instance.enemyList.Add(target);
            break;

        case ObjectType.Goal:
            print("Goal Established");
            break;

        default:
            Debug.LogError("ERROR: GENERATED OBJECT DOESN'T HAVE A COMPATIBLE TYPE!");
            break;
        }
    }
Exemple #3
0
    bool OnAdjacentCheck(TerrainCubeData inputData, ObjectFacing inputFacing)
    {
        GameObject adjacentTile;

        bool output = false;


        switch (inputFacing)
        {
        case ObjectFacing.North:
            adjacentTile = MapManager._Instance.RequestMapTile(inputData.gridPosition.posX, inputData.gridPosition.posY + 1);
            if (adjacentTile != null)
            {
                print("Checking North");
                output = true;
            }
            break;

        case ObjectFacing.South:
            adjacentTile = MapManager._Instance.RequestMapTile(inputData.gridPosition.posX, inputData.gridPosition.posY - 1);
            if (adjacentTile != null)
            {
                print("Checking South");
                output = true;
            }
            break;

        case ObjectFacing.East:
            adjacentTile = MapManager._Instance.RequestMapTile(inputData.gridPosition.posX + 1, inputData.gridPosition.posY);
            if (adjacentTile != null)
            {
                print("Checking East");
                output = true;
            }
            break;

        case ObjectFacing.West:
            adjacentTile = MapManager._Instance.RequestMapTile(inputData.gridPosition.posX - 1, inputData.gridPosition.posY);
            if (adjacentTile != null)
            {
                print("Checking West");
                output = true;
            }
            break;

        default:
            break;
        }

        return(output);
    }
Exemple #4
0
    // (!) Generate test block in Coord (3,3) and (4,2).

    void CreateMapObject(GameObject inputObject, ObjectFacing inputFacing, int inputPosX, int inputPosY)
    {
        foreach (GameObject target in terrainList)
        {
            TerrainCubeData tempData = target.GetComponent <TerrainCubeData> ();

            if (tempData.gridPosition.posX == inputPosX && tempData.gridPosition.posY == inputPosY && CheckTile(inputPosX, inputPosY))
            {
                print("Generating: " + inputObject.name + " in " + inputPosX + "," + inputPosY);
                GameObject go = GameObject.Instantiate(inputObject, Vector3.zero, transform.rotation);
                go.transform.SetParent(target.transform, false);
                go.transform.localPosition = new Vector3(0f, objectOffset, 0f);
                tempData.occupant          = go;
                ObjectPostConfig(go, inputFacing);
            }
        }
    }
Exemple #5
0
    public IEnumerator PlayDirectionAnimation(ObjectFacing inputFacing)
    {
        print("playing");
        isPlaying = true;
        GetComponent <ObjectMovement>().facingConfig = inputFacing;
        GetComponent <ObjectMovement>().UpdateFacing();
        objectAnimator.SetTrigger("isRolling");
        objectAnimator.SetBool("isPlaying", true);
        yield return(new WaitForSeconds(ApplyTranslation()));

        while (isPlaying)
        {
            yield return(null);
        }
        print("end animation");
        isPlaying = false;
    }
Exemple #6
0
    bool CheckFacing(ObjectFacing inputFacing, ObjectFacing targetFacing)
    {
        bool output = false;

        switch (inputFacing)
        {
        case ObjectFacing.North:
            if (targetFacing == ObjectFacing.South)
            {
                output = true;
            }
            break;

        case ObjectFacing.South:
            if (targetFacing == ObjectFacing.North)
            {
                output = true;
            }
            break;

        case ObjectFacing.East:
            if (targetFacing == ObjectFacing.West)
            {
                output = true;
            }
            break;

        case ObjectFacing.West:
            if (targetFacing == ObjectFacing.East)
            {
                output = true;
            }
            break;

        default:
            break;
        }

        return(output);
    }
Exemple #7
0
    // Experimental function to pre-set facing according to position targeting calculations.
    public void SetFacingDirection(int inputX, int inputY, int inputTargetX, int inputTargetY)
    {
        //Set Direction to - East
        if (inputX - inputTargetX < 0 && inputY - inputTargetY == 0)
        {
            facingConfig = ObjectFacing.East;
        }
        if (inputX - inputTargetX > 0 && inputY - inputTargetY == 0) // Set Direction to - West
        {
            facingConfig = ObjectFacing.West;
        }

        //Set Direction to - South
        if (inputY - inputTargetY < 0 && inputX - inputTargetX == 0)
        {
            facingConfig = ObjectFacing.North;
        }
        if (inputY - inputTargetY > 0 && inputX - inputTargetX == 0) // Set Direction to - North
        {
            facingConfig = ObjectFacing.South;
        }
    }
Exemple #8
0
    bool PostPushCheck(ObjectFacing inputFacing)
    {
        GameObject tempMapObject;
        bool       output = false;

        // WHAT WILL I DO HERE?!
        switch (inputFacing)
        {
        case ObjectFacing.North:
            tempMapObject = MapManager._Instance.RequestMapTile(positionX, positionY + 1);
            if (tempMapObject != null)
            {
                if (tempMapObject.GetComponent <TerrainCubeData>().occupant != null)
                {
                    //	if(tempMapObject.GetComponent<TerrainCubeData>().occupant.GetComponent<MapObjectData>().type == ObjectType.Wall)
                    //	{
                    output = true;
                    GetComponent <ObjectAnimationManager>().targetPosition = tempMapObject.transform.localPosition;
                    //	}
                }
            }

            break;

        case ObjectFacing.South:
            tempMapObject = MapManager._Instance.RequestMapTile(positionX, positionY - 1);
            if (tempMapObject != null)
            {
                if (tempMapObject.GetComponent <TerrainCubeData>().occupant != null)
                {
                    //	if(tempMapObject.GetComponent<TerrainCubeData>().occupant.GetComponent<MapObjectData>().type == ObjectType.Wall)
                    //	{
                    output = true;
                    GetComponent <ObjectAnimationManager>().targetPosition = tempMapObject.transform.localPosition;
                    //	}
                }
            }
            break;

        case ObjectFacing.East:
            tempMapObject = MapManager._Instance.RequestMapTile(positionX + 1, positionY);
            if (tempMapObject != null)
            {
                if (tempMapObject.GetComponent <TerrainCubeData>().occupant != null)
                {
                    //	if(tempMapObject.GetComponent<TerrainCubeData>().occupant.GetComponent<MapObjectData>().type == ObjectType.Wall)
                    //	{
                    output = true;
                    GetComponent <ObjectAnimationManager>().targetPosition = tempMapObject.transform.localPosition;
                    //	}
                }
            }
            break;

        case ObjectFacing.West:
            tempMapObject = MapManager._Instance.RequestMapTile(positionX - 1, positionY);
            if (tempMapObject != null)
            {
                if (tempMapObject.GetComponent <TerrainCubeData>().occupant != null)
                {
                    //	if(tempMapObject.GetComponent<TerrainCubeData>().occupant.GetComponent<MapObjectData>().type == ObjectType.Wall)
                    //	{
                    output = true;
                    GetComponent <ObjectAnimationManager>().targetPosition = tempMapObject.transform.localPosition;
                    //	}
                }
            }
            break;

        default:
            break;
        }

        return(output);
    }
Exemple #9
0
    void SelectTargetObjectType(ObjectType inputType, TerrainCubeData inputData, GameObject inputTerrain, ObjectFacing inputFacing)
    {
        switch (inputType)
        {
        // Case doesn't allow movement effect on wall.
        case ObjectType.Wall:

            // Preemptive check to avoid null-reference if Player is adyacent to a wall.
            if (lastObjectChecked != null)
            {
                selectableTargets.Add(lastObjectChecked.GetComponent <TerrainCubeData>().gridPosition);
                lastObjectChecked.GetComponent <TerrainCubeData>().ChangeMaterial(MapManager._Instance.materialPool[3], false);
            }
            break;

        case ObjectType.Enemy:
            if (lastObjectChecked != null)
            {
                selectableTargets.Add(inputTerrain.GetComponent <TerrainCubeData>().gridPosition);
                inputData.ChangeMaterial(MapManager._Instance.materialPool[3], false);
            }
            break;


        case ObjectType.Goal:
            if (lastObjectChecked != null)
            {
                selectableTargets.Add(inputTerrain.GetComponent <TerrainCubeData> ().gridPosition);
                inputData.ChangeMaterial(MapManager._Instance.materialPool [3], false);
            }
            break;

        case ObjectType.Player:
            if (lastObjectChecked != null)
            {
                selectableTargets.Add(inputTerrain.GetComponent <TerrainCubeData>().gridPosition);
                inputData.ChangeMaterial(MapManager._Instance.materialPool[3], false);
            }

            break;

        case ObjectType.DirectionalMove:
            if (CheckFacing(inputFacing, inputTerrain.GetComponent <TerrainCubeData> ().occupant.GetComponent <ObjectMovement> ().facingConfig))
            {
                selectableTargets.Add(inputTerrain.GetComponent <TerrainCubeData> ().gridPosition);
                inputData.ChangeMaterial(MapManager._Instance.materialPool [3], false);
            }
            else
            {
                if (lastObjectChecked != null)
                {
                    selectableTargets.Add(lastObjectChecked.GetComponent <TerrainCubeData>().gridPosition);
                    lastObjectChecked.GetComponent <TerrainCubeData>().ChangeMaterial(MapManager._Instance.materialPool[3], false);
                }
            }
            break;

        default:
            break;
        }
    }