Beispiel #1
0
 public void travelLeft()
 {
     if (Exploring.coords.x - 1 >= 0 &&
         Exploring.currentMap.map[(int)Exploring.coords.y][(int)Exploring.coords.x - 1].type != "noTile")
     {
         Exploring.coords.x -= 1;
         Exploring.activateTile();
     }
 }
Beispiel #2
0
 public void travelRight()
 {
     if (Exploring.coords.x + 1 < Exploring.currentMap.map[(int)Exploring.coords.y].Count &&
         Exploring.currentMap.map[(int)Exploring.coords.y][(int)Exploring.coords.x + 1].type != "noTile")
     {
         Exploring.coords.x += 1;
         Exploring.activateTile();
     }
 }
Beispiel #3
0
 public void travelDown()
 {
     if (Exploring.coords.y + 1 < Exploring.currentMap.map.Count &&
         Exploring.currentMap.map[(int)Exploring.coords.y + 1][(int)Exploring.coords.x].type != "noTile")
     {
         Exploring.coords.y += 1;
         Exploring.activateTile();
     }
 }
Beispiel #4
0
    private void Start()
    {
        Exploring.moveToStart();

        //item types
        itemList.Add("testitem1", new Item("testitem1", 3, itemTexList[0], Combat.fireball));

        //test items
        give(itemList["testitem1"]);
    }
Beispiel #5
0
 //Button Triggers
 public void fakeTrigger()
 {
     if (GameHandler.gameState == GameHandler.GameState.inField && Exploring.currentMap.isCheckpoint)
     {
         Exploring.embark(Exploring.testMap);
     }
     else if (GameHandler.gameState == GameHandler.GameState.inField)
     {
         Combat.battleTrigger(Combat.listOfBattles[Mathf.FloorToInt(Random.Range(0, Combat.listOfBattles.Count - 0.1f))]);
     }
     else
     {
         Combat.battleWin();
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="slaveMacId"></param>
        /// <returns></returns>
        public ISlaveDevice GetSlaveByMacId(int slaveMacId)
        {
            foreach (var dev in Devices)
            {
                if (dev.SlaveMacId == slaveMacId)
                {
                    return(dev);
                }
            }

            Exploring.RunSync();

            foreach (var dev in Devices)
            {
                if (dev.SlaveMacId == slaveMacId)
                {
                    return(dev);
                }
            }

            throw new DeviceNetException("DeviceNet: Slave device not found. SlaveMacId:" + slaveMacId.ToString());
        }
Beispiel #7
0
    private void OnGUI()
    {
        foreach (Unit unit in Combat.currentBattle)
        {
            //draw health bars
            var newRect = healthBarRect;
            newRect.x = Camera.main.WorldToScreenPoint(unit.gameObject.transform.position).x - healthBarRect.x;
            GUI.Box(newRect, "");

            var newRect2 = newRect;
            newRect2.width *= unit.hp / unit.maxhp;
            GUI.Box(newRect2, "HP: " + unit.hp, healthBarStyle);

            //draw MOV pips
            for (int i = unit.mov; i > 0; i--)
            {
                var tempMOVpipsRect = MOVPipsRect;
                tempMOVpipsRect.x = newRect2.x + MOVPipsRect.x + i * (MOVPipsRect.width + MOVPipsMargins);
                tempMOVpipsRect.y = healthBarRect.y + MOVPipsRect.y;
                GUI.Box(tempMOVpipsRect, "", MOVPipsStyle);
            }
        }

        //draw movement arrows
        if (GameHandler.gameState == GameHandler.GameState.inBattle && uiState != UIState.disabled)
        {
            //draw moveLeft arrow at 370, 315, 75, 75
            if (GUI.Button(leftMoveRect, new GUIContent(leftMoveTex), emptyStyle))
            {
                if (Combat.currentTurn >= 1)
                {
                    playerMoveLeft();
                }
                audioSources[0].Play();
            }

            //draw moveRight arrow at 550, 315, 75, 75
            if (GUI.Button(rightMoveRect, new GUIContent(rightMoveTex), emptyStyle))
            {
                playerMoveRight();
                audioSources[0].Play();
            }
        }

        //draw exploration arrows
        if (uiState == UIState.exploring)
        {
            //draw up arrow
            if (Exploring.adjecentToTile("up") && GUI.Button(upArrowRect, new GUIContent(upArrowTex, "Move Up"), emptyStyle))
            {
                travelUp();
                audioSources[0].Play();
            }
            //draw down arrow
            if (Exploring.adjecentToTile("down") && GUI.Button(downArrowRect, new GUIContent(downArrowTex, "Move Down"), emptyStyle))
            {
                travelDown();
                audioSources[0].Play();
            }
            //draw left arrow
            if (Exploring.adjecentToTile("left") && GUI.Button(leftArrowRect, new GUIContent(leftArrowTex, "Move Left"), emptyStyle))
            {
                travelLeft();
                audioSources[0].Play();
            }
            //draw right arrow
            if (Exploring.adjecentToTile("right") && GUI.Button(rightArrowRect, new GUIContent(rightArrowTex, "Move Right"), emptyStyle))
            {
                travelRight();
                audioSources[0].Play();
            }

            //draw map
            showMap = GUI.Toggle(new Rect(mapIconRect.x + 20, mapIconRect.y - 20, 40, 40), showMap, new GUIContent());
            if (showMap)
            {
                drawMap();
            }

            //draw exit button
            var mapString = Exploring.getCurrentTile().mapString;
            if (mapString != null)
            {
                if (GUI.Button(leaveRect, new GUIContent("Leave", leaveTex)))
                {
                    Exploring.embark(Exploring.getMap(mapString));
                }
            }

            //draw dialogue button
            var currentDialogueString = Exploring.getCurrentTile().dialogue;
            if (currentDialogueString != null)
            {
                if (GUI.Button(dialogueStartRect, new GUIContent("Talk to " + DialogueHandler.findDialogue(currentDialogueString).characterName, dialogueStartTex)))
                {
                    uiState = UIState.conversing;
                    DialogueHandler.startConversation(currentDialogueString);
                }
            }
        }

        //draw dialogue box
        else if (uiState == UIState.conversing)
        {
            GUI.Box(dialogueBoxRect, new GUIContent(DialogueHandler.currentSentence));

            if (DialogueHandler.currentFullSentence.choices.Count < 1)
            {
                if (GUI.Button(dialogueContinueRect, new GUIContent("Next", dialogueContinueTex)))
                {
                    DialogueHandler.displayNextSentence();
                }
            }
            else
            {
                Rect tempRect = dialogueContinueRect;
                var  choices  = DialogueHandler.currentFullSentence.choices;

                for (int i = 0; i < choices.Count; i++)
                {
                    string choice = choices[i];
                    tempRect.x = dialogueBoxRect.x - dialogueContinueRect.width / 2 + dialogueBoxRect.width / (choices.Count + 1) * (i + 1);

                    if (GUI.Button(tempRect, new GUIContent(DialogueHandler.findDialogue(choice).name)))
                    {
                        DialogueHandler.startConversation(choice);
                    }
                }
            }
        }

        //draw combat actions
        else if (uiState == UIState.action)
        {
            //draw attack button at 300, 400, 200, 40
            if (GUI.Button(attackRect, new GUIContent("Attack", attackTex), actionStyle))
            {
                Combat.setCurrentAttack(Combat.attack);
                uiState = UIState.attacking;
            }

            //draw inventory button at 300, 450, 200, 40
            if (GUI.Button(invRect, new GUIContent("Inventory", invTex), actionStyle))
            {
                uiState = UIState.inventory;
            }
        }

        //draw attack targets
        else if (uiState == UIState.attacking)
        {
            //draw attack button at 300, 400, 200, 40
            if (GUI.Button(attackRect, new GUIContent("Attack", attackTex), actionStyle))
            {
                Combat.nullCurrentAttack();
                uiState = UIState.action;
            }
        }

        //draw inventory
        else if (uiState == UIState.inventory)
        {
            //draw inventory button at 300, 450, 200, 40
            if (GUI.Button(attackRect, new GUIContent("Inventory", invTex), actionStyle))
            {
                uiState = UIState.action;
            }

            drawInv();

            if (Combat.currentItem != null)
            {
                GUI.Label(new Rect(Event.current.mousePosition, new Vector2(50, 50)), new GUIContent(Combat.currentItem.tex));
            }
        }

        //draw Tooltip
        GUI.Label(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 400, 10), GUI.tooltip, emptyStyle);

        //what the f**k unity (works while true)
        if (shouldRepeat)
        {
            shouldRepeat = false;
        }
        else
        {
            shouldRepeat = true;
        }
    }