コード例 #1
0
    public void SpawnMessage(MazeNode node, GameObject messages)
    {
        float      xtranslation;
        float      ztranslation;
        int        messageType = (int)messageRand.Next(0, 3) + 1;
        GameObject message;

        if (node.GetRotation().Equals(Quaternion.Euler(new Vector3(0, 90, 0))))
        {
            xtranslation = (float)-6.2;
            ztranslation = 0;
        }
        else if (node.GetRotation().Equals(Quaternion.Euler(new Vector3(0, -90, 0))))
        {
            xtranslation = (float)5.3;
            ztranslation = 0;
        }
        else if (node.GetRotation().Equals(Quaternion.Euler(new Vector3(0, 180, 0))))
        {
            xtranslation = 0;
            ztranslation = (float)5.3;
        }
        else if (node.GetRotation().Equals(Quaternion.Euler(new Vector3(0, 0, 0))))
        {
            xtranslation = 0;
            ztranslation = (float)-6.2;
        }
        else
        {
            xtranslation = 0;
            ztranslation = 0;
        }
        Vector3 loc = new Vector3(node.Col * 6 + 8 + xtranslation, (float)(node.Floor * 30 + 1), node.Row * 6 + 8 + ztranslation);

        if (node.MessageNode)
        {
            message = Instantiate(Resources.Load("Prefabs/Messages/Message" + messageType.ToString()), loc, node.GetRotation()) as GameObject;
            message.transform.parent = messages.transform;
        }
    }
コード例 #2
0
    public void SpawnActor(MazeNode node, GameObject actors)
    {
        GameObject actorObject;
        Vector3    location = new Vector3(node.Col * 6 + 8, node.Floor * 30, node.Row * 6 + 8);

        if (node.actor != ActorType.Null)
        {
            if (node.actor == ActorType.Okuri_Inu || node.actor == ActorType.Oni || node.actor == ActorType.Taka_Nyudo)
            {
                //print("Column: " + node.Col + " Row: " + node.Row);
                node.EnemyPathNode = true;
            }
            if (node.actor == ActorType.Pit_Trap)// || node.actor == ActorType.Spike_Trap)
            {
                node.floorPrefab.SetActive(false);
            }

            if (node.actor == ActorType.Ladder)
            {
                if (node.ladderMazeNode == null)
                {
                    actorObject = Instantiate(Resources.Load("Prefabs/Level/LadderUp"), location, node.GetRotation()) as GameObject;
                }
                else if (node.ladderMazeNode.Floor > node.Floor)
                {
                    actorObject = Instantiate(Resources.Load("Prefabs/Level/LadderUp"), location, node.GetRotation()) as GameObject;
                }
                else
                {
                    actorObject = Instantiate(Resources.Load("Prefabs/Level/LadderDown"), location, node.GetRotation()) as GameObject;
                }
            }

            else
            {
                actorObject = Instantiate(Actors.Prefabs[node.actor], location, node.GetRotation());
            }

            actorObject.transform.parent = actors.transform;
            if (node.actor == ActorType.Ladder)
            {
                node.ladder = actorObject;
                node.ladder.GetComponent <Ladder>().SectionID           = node.SectionID;
                node.ladder.GetComponent <Ladder>().ConnectedLadderNode = node.ladderMazeNode;
                node.ladder.GetComponent <Ladder>().location            = node;
            }
            actorObject.AddComponent <Actor>().ActorID = AnalyticsManager.AddActor(SessionID, node.actor);
            actorObject.GetComponent <Actor>().type    = node.actor;
        }
    }
コード例 #3
0
    public void SpawnPiece(MazeNode node, GameObject cells, int sectionID)
    {
        Vector3 location = new Vector3(node.Col * 6 + 8, node.Floor * 30, node.Row * 6 + 8);

        GameObject obj = Instantiate(Resources.Load(node.GetPrefabName()), location, node.GetRotation()) as GameObject;

        obj.transform.parent = cells.transform;
        node.floorPrefab     = obj.transform.GetChild(0).gameObject;
        GameObject cellObj = Instantiate(Resources.Load("Prefabs/Level/CellLog"), location, node.GetRotation()) as GameObject;

        cellObj.transform.parent = obj.transform;
        CellLog cellLog = cellObj.GetComponent <CellLog>();

        cellLog.Row    = node.Row;
        cellLog.Col    = node.Col;
        cellLog.CellID = AnalyticsManager.AddCell(sectionID, node.Col, node.Row);
        obj.name       = "Cell " + cellLog.CellID;

        if (DebugLabelsOn)
        {
            GameObject textObj = Instantiate(Resources.Load("Prefabs/Level/CellTextPrefab"), location + new Vector3(0, 0.5f, -1), new Quaternion()) as GameObject;
            textObj.transform.parent = obj.transform;

            TextMesh t = textObj.GetComponentInChildren <TextMesh>();
            if (t != null)
            {
                t.text = "R: " + node.Row + " C: " + node.Col;
            }

            textObj = Instantiate(Resources.Load("Prefabs/Level/CellTextPrefab"), location + new Vector3(0, 0.5f, 0), new Quaternion()) as GameObject;
            textObj.transform.parent = obj.transform;

            t = textObj.GetComponentInChildren <TextMesh>();
            if (t != null)
            {
                t.text = "P" + piecesSpawned++;
            }
        }
    }
コード例 #4
0
    // TODO Add an Actor Component to each actor GameObject

    public void SpawnLantern(MazeNode node, GameObject lanterns)
    {
        float rAlter;
        float bAlter;
        float gAlter;
        Color colorTemp = sectionLanternColor;

        if (sectionLanternColor.r == 1)
        {
            rAlter = ((float)(hueRand.Next(-10, 0))) / 255;
        }
        else if (sectionLanternColor.r == 0)
        {
            rAlter = ((float)(hueRand.Next(0, 11))) / 255;
        }
        else
        {
            rAlter = ((float)(hueRand.Next(-10, 11))) / 255;
        }

        if (sectionLanternColor.b == 1)
        {
            bAlter = ((float)(hueRand.Next(-10, 0))) / 255;
        }
        else if (sectionLanternColor.b == 0)
        {
            bAlter = ((float)(hueRand.Next(0, 11))) / 255;
        }
        else
        {
            bAlter = ((float)(hueRand.Next(-10, 11))) / 255;
        }

        if (sectionLanternColor.g == 1)
        {
            gAlter = ((float)(hueRand.Next(-10, 0))) / 255;
        }
        else if (sectionLanternColor.g == 0)
        {
            gAlter = ((float)(hueRand.Next(0, 11))) / 255;
        }
        else
        {
            gAlter = ((float)(hueRand.Next(-10, 11))) / 255;
        }

        colorTemp.r += rAlter;
        colorTemp.b += bAlter;
        colorTemp.g += gAlter;

        //print("Red: " + colorTemp.r + " Blue: " + colorTemp.b + " Green: " + colorTemp.g);

        GameObject lantern;
        Vector3    loc = new Vector3(node.Col * 6 + 8, (float)(node.Floor * 30 + 6.5), node.Row * 6 + 8);

        if ((node.Col + node.Row) % 2 == 0)
        {
            lantern = Instantiate(Resources.Load("Prefabs/Level/Lantern"), loc, node.GetRotation()) as GameObject;
            lantern.transform.GetChild(1).GetComponent <Light>().color = colorTemp;
            lantern.transform.GetChild(0).GetChild(0).GetComponent <Renderer>().material.color = colorTemp;
            lantern.transform.GetChild(0).GetChild(0).GetComponent <Renderer>().material.SetColor("_EmissionColor", colorTemp);
            lantern.transform.GetChild(1).GetComponent <Light>().intensity = ((float)intensityRand.Next(1, 6)) / 10;
            lantern.transform.parent = lanterns.transform;
        }
    }