Esempio n. 1
0
    public void SetArrow(bool[] array, NodeChoice node, GamePosition gamePosition)
    {
        if(gamePosition == GamePosition.Up)
        {
            up = upGame;
        }else{
            up = upMove;
        }
        if(gamePosition == GamePosition.Down)
        {
            down = downGame;
        }else{
            down = downMove;
        }
        if(gamePosition == GamePosition.Left)
        {
            left = leftGame;
        }else{
            left = leftMove;
        }
        if(gamePosition == GamePosition.Right)
        {
            right = rightGame;
        }else{
            right = rightMove;
        }

        this.upOn = array[0];
        this.downOn = array[1];
        this.leftOn = array[2];
        this.rightOn = array[3];
        isGirlOn = true;
        this.node = node;
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.O))
        {
            StartTurn();
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            EndTurn();
        }

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            NodeChoice         currentNode    = NodeChoices[currentIndexChoice];
            NodeChoice.Choices nextNodeChoice = currentNode.UpChoice;
            SelectAction(nextNodeChoice);
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            NodeChoice         currentNode    = NodeChoices[currentIndexChoice];
            NodeChoice.Choices nextNodeChoice = currentNode.DownChoice;
            SelectAction(nextNodeChoice);
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            NodeChoice         currentNode    = NodeChoices[currentIndexChoice];
            NodeChoice.Choices nextNodeChoice = currentNode.RightChoice;
            SelectAction(nextNodeChoice);
        }
        else if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            NodeChoice         currentNode    = NodeChoices[currentIndexChoice];
            NodeChoice.Choices nextNodeChoice = currentNode.LeftChoice;
            SelectAction(nextNodeChoice);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            // if (playerTurn == false) DO NOTHING
            // TODO: bind keyboard action to trigger the action commande.
            //ActionButtons[nextActionButtonIndex].GetComponent<Button>().TriggerClickAction
        }
    }
Esempio n. 3
0
    void SelectAction(NodeChoice.Choices nextNodeChoice)
    {
        if (!playerTurn)
        {
            return;
        }
        int nextActionButtonIndex = NodeChoice.ActionButtonIndex(nextNodeChoice);

        if (nextActionButtonIndex < 0)
        {
            return;
        }

        previousIndexChoice = currentIndexChoice;
        currentIndexChoice  = nextActionButtonIndex;

        if (previousIndexChoice != -1)
        {
            ActionButtons[previousIndexChoice].GetComponent <Image>().color = NotSelectedButtonColor;
        }

        ActionButtons[nextActionButtonIndex].GetComponent <Image>().color = SelectedButtonColor;
    }
Esempio n. 4
0
 public void RemoveArrow()
 {
     isGirlOn = false;
     node = null;
 }
Esempio n. 5
0
        internal static async void MonitorUpdates()
        {
#if !DEBUG
            try
#endif
            {
                var baseDirectory   = Path.Combine(Bot.RootDirectory, ".."); //go up one directory
                var updateDirectory = Path.Combine(Bot.RootDirectory, "Update");
                while (Bot.Nodes.Count == 0)
                {
                    await Task.Delay(500);
                }
                var currentVersion = Bot.Nodes.Max(x => Version.Parse(x.Version));
                var currentChoice  = new NodeChoice();
                while (true)
                {
                    //check nodes first
                    foreach (var dir in Directory.GetDirectories(baseDirectory, "*Node*"))
                    {
                        //get the node exe in this directory
                        var     file = Directory.GetFiles(dir, "Werewolf Node.exe").First();
                        Version fvi  = Version.Parse(FileVersionInfo.GetVersionInfo(file).FileVersion);
                        if (fvi > currentChoice.Version)
                        {
                            currentChoice.Path    = file;
                            currentChoice.Version = fvi;
                        }
                    }
                    if (currentChoice.Version > currentVersion)
                    {
                        currentVersion = currentChoice.Version;
                        //alert dev group
                        Bot.Send($"New node with version {currentVersion} found.  Stopping old nodes.", -1001077134233);
                        //kill existing nodes
                        foreach (var node in Bot.Nodes)
                        {
                            node.ShutDown();
                        }
                        await Task.Delay(500);

                        foreach (var node in Bot.Nodes)
                        {
                            node.ShutDown();
                        }
                    }

                    //now check for Control update
                    if (Directory.GetFiles(updateDirectory).Count() > 1)
                    {
                        //update available
                        //sleep 5 seconds to allow any nodes to connect and whatnot.
                        await Task.Delay(5000);

                        //await Bot.Send($"New control found.  Updating.", -1001077134233);
                        //fire off the updater
                        Process.Start(Path.Combine(Bot.RootDirectory, "Resources\\update.exe"), "-1001077134233");
                        Bot.Running     = false;
                        Program.Running = false;
                        Bot.Api.StopReceiving();
                        //Thread.Sleep(500);
                        using (var db = new WWContext())
                        {
                            var bot =
#if DEBUG
                                4;
#elif BETA
                                3;
#elif RELEASE
                                1;
#elif RELEASE2
                                2;
#endif

#if !DEBUG
                            var status = await db.BotStatus.FindAsync(bot);

                            status.BotStatus = "Updating";
                            await db.SaveChangesAsync();
#endif
                        }
                        Environment.Exit(1);
                    }


                    //check once every 5 seconds
                    await Task.Delay(5000);
                }
                //now we have the most recent version, launch one
            }
#if !DEBUG
            catch (Exception e)
            {
                Bot.Send($"Error in update monitor: {e.Message}\n{e.StackTrace}", -1001077134233, parseMode: ParseMode.Default);
            }
#endif
        }