Exemplo n.º 1
0
 private void Reset()
 {
     if (Controller != null && cooldown >= Cooldown)
     {
         Controller.transform.rotation = Quaternion.identity;
         cooldown = 0;
         Button.Disable();
         CountdownLabel.Show();
         CountdownLabel.Text = string.Format("{0:0.00}", Cooldown - cooldown);
     }
 }
Exemplo n.º 2
0
    public void Setup(int iPages, int iCurrentPage)
    {
        if (this.pageCount == iPages && this.pageCurrent == iCurrentPage)
        {
            return;
        }
        this.pageCount   = iPages;
        this.pageCurrent = iCurrentPage;
        dfControl[] componentsInChildren = base.gameObject.GetComponentsInChildren <dfControl>();
        for (int i = 0; i < (int)componentsInChildren.Length; i++)
        {
            dfControl _dfControl = componentsInChildren[i];
            if (_dfControl.gameObject != base.gameObject)
            {
                UnityEngine.Object.Destroy(_dfControl.gameObject);
            }
        }
        if (this.pageCount <= 1)
        {
            return;
        }
        dfControl component = base.GetComponent <dfControl>();
        bool      flag      = true;
        Vector3   vector3   = new Vector3(0f, 0f, 0f);

        for (int j = 0; j < this.pageCount; j++)
        {
            if (this.buttonGroups - j > 0 || j >= this.pageCount - this.buttonGroups || Math.Abs(j - this.pageCurrent) <= this.buttonGroups / 2)
            {
                dfButton str = ((GameObject)UnityEngine.Object.Instantiate(this.clickableButton)).GetComponent <dfButton>();
                component.AddControl(str);
                str.Tooltip    = j.ToString();
                str.MouseDown += new MouseEventHandler(this.OnButtonClicked);
                str.Text       = (j + 1).ToString();
                str.Invalidate();
                if (j == this.pageCurrent)
                {
                    str.Disable();
                }
                str.Position = vector3;
                vector3.x    = vector3.x + (str.Width + 5f);
                flag         = true;
            }
            else
            {
                if (flag)
                {
                    this.DropSpacer(ref vector3);
                }
                flag = false;
            }
        }
        component.Width = vector3.x;
    }
Exemplo n.º 3
0
 public void Setup(int iPages, int iCurrentPage)
 {
     if ((this.pageCount != iPages) || (this.pageCurrent != iCurrentPage))
     {
         this.pageCount   = iPages;
         this.pageCurrent = iCurrentPage;
         foreach (dfControl control in base.gameObject.GetComponentsInChildren <dfControl>())
         {
             if (control.gameObject != base.gameObject)
             {
                 Object.Destroy(control.gameObject);
             }
         }
         if (this.pageCount > 1)
         {
             dfControl component = base.GetComponent <dfControl>();
             bool      flag      = true;
             Vector3   vPos      = new Vector3(0f, 0f, 0f);
             for (int i = 0; i < this.pageCount; i++)
             {
                 if ((((this.buttonGroups - i) <= 0) && (i < (this.pageCount - this.buttonGroups))) && (Math.Abs((int)(i - this.pageCurrent)) > (this.buttonGroups / 2)))
                 {
                     if (flag)
                     {
                         this.DropSpacer(ref vPos);
                     }
                     flag = false;
                 }
                 else
                 {
                     dfButton child = ((GameObject)Object.Instantiate(this.clickableButton)).GetComponent <dfButton>();
                     component.AddControl(child);
                     child.Tooltip    = i.ToString();
                     child.MouseDown += new MouseEventHandler(this.OnButtonClicked);
                     child.Text       = (i + 1).ToString();
                     child.Invalidate();
                     if (i == this.pageCurrent)
                     {
                         child.Disable();
                     }
                     child.Position = vPos;
                     vPos.x        += child.Width + 5f;
                     flag           = true;
                 }
             }
             component.Width = vPos.x;
         }
     }
 }
    public void OnClick(dfControl control, dfMouseEventArgs mouseEvent)
    {
        // Add event handler code here

        foreach (var player in PhotonNetwork.otherPlayers)
        {
            if (player.currentState == PhotonPlayer.State.ATTACKER)
            {
                canAssign = false;
            }
        }

        if (canAssign)
        {
            PhotonNetwork.player.currentState = PhotonPlayer.State.ATTACKER;
            _button.Disable();
        }

        Debug.Log("Click");
    }
Exemplo n.º 5
0
    void GenerateList(string filter)
    {
        //Player current = Player.CurrentUser as Player;

        //current.Get<string>("email");

        //IList<Player> players = null;

        //try
        //{
        //    players = current.Get<IList<Player>>("pinnedPlayers");
        //}
        //catch (Exception e)
        //{

        //}
        //if (players == null)
        //{
        //    print("players is null");
        //    players = new List<Player>() { users.LastOrDefault() };
        //}
        //print("count " + players.Count);
        //players.Add(users.FirstOrDefault());
        //current["pinnedPlayers"] = players;
        //current.SaveAsync();

        //current.PinnedPlayers.FetchAllAsync().ContinueWith(t =>
        //{
        //    if (current.PinnedPlayers != null)
        //    {
        //        foreach (Player p in current.PinnedPlayers)
        //        {
        //            print("Player: " + p.Username);
        //        }
        //    }



        //    current.PinnedPlayers.Add(users.LastOrDefault());
        //    current.SaveAsync();
        //    print("Saving pinnedPlayers");
        //});


        var children = new List <GameObject>();

        foreach (Transform child in UserPanel.transform)
        {
            children.Add(child.gameObject);
        }
        children.ForEach(child => Destroy(child));

        UserPanel.Enable();

        IEnumerable <Player> filtered = users.Where(t => t.Username.ToLower().Contains(filter.ToLower())).OrderByDescending(t => t.ObjectId.Equals(Player.CurrentUser.ObjectId))
                                        .ThenByDescending(t => friendList.Contains(t.ObjectId));

        foreach (Player player in filtered)
        {
            ParseObject friend = null;
            if (friends != null)
            {
                friend = friends.Where(t => ((Player)t[REQUEST_FROM]).ObjectId.Equals(player.ObjectId) || ((Player)t[REQUEST_TO]).ObjectId.Equals(player.ObjectId)).FirstOrDefault();

                //    friend = friends.FirstOrDefault();
                //   print("Friend: " + ((Player)friend[REQUEST_TO]).ObjectId);
                //    print("Player: " + player.ObjectId);
            }

            // GameObject ListItem = Instantiate(Resources.Load("List Item")) as GameObject;
            dfPanel listItem = UserPanel.AddPrefab(ListItem) as dfPanel; // as UserListItem;
            listItem.Width = UserPanel.Width - UserPanel.FlowPadding.left - UserPanel.FlowPadding.right;

            ListItemExtras extras = listItem.GetComponent <ListItemExtras>();
            extras.Player        = player;
            extras.FriendRequest = friend;

            dfLabel username = listItem.Find("Username Label").GetComponent <dfLabel>();
            username.Text          = player.Username;
            username.DisabledColor = new Color32(100, 100, 100, 255);

            dfLabel email = listItem.Find("Email label").GetComponent <dfLabel>();
            email.Text          = player.Email;
            email.DisabledColor = new Color32(100, 100, 100, 255);

            dfSprite onlineSprite = listItem.Find("Online Sprite").GetComponent <dfSprite>();
            if (player.IsOnline)
            {
                onlineSprite.SpriteName = "OUYA_O 24px";
            }
            else
            {
                onlineSprite.SpriteName = "OUYA_A 24px";
            }

            dfButton actionButton = listItem.Find("Action Button").GetComponent <dfButton>();
            if (friend == null)
            {
                actionButton.Text   = "Add";
                actionButton.Click += new MouseEventHandler(actionClick_add);
            }
            else
            {
                string status = friend[STATUS] as string;
                Player from   = friend[REQUEST_FROM] as Player;
                if (Player.CurrentUser.ObjectId.Equals(from.ObjectId))
                {
                    switch (status)
                    {
                    case S_ACCEPTED:
                        actionButton.Text        = "Remove";
                        actionButton.Click      += new MouseEventHandler(actionClick_remove);
                        listItem.BackgroundColor = new Color32(200, 255, 200, 255);
                        break;

                    case S_REJECTED:
                        actionButton.Text = "Sorry";
                        break;

                    case S_PENDING:
                        actionButton.Text = "Pending";
                        actionButton.Disable();
                        break;
                    }
                }
                else
                {
                    switch (status)
                    {
                    case S_ACCEPTED:
                        actionButton.Text        = "Remove";
                        actionButton.Click      += new MouseEventHandler(actionClick_remove);
                        listItem.BackgroundColor = new Color32(200, 255, 200, 255);
                        break;

                    case S_REJECTED:
                        actionButton.Text = "Rejected";
                        break;

                    case S_PENDING:
                        actionButton.Text   = "Accept";
                        actionButton.Click += new MouseEventHandler(actionClick_accept);
                        break;
                    }
                }
            }

            if (player.Username.Equals(Player.CurrentUser.Username))
            {
                actionButton.Hide();
            }
        }
    }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        this._panel = GetComponent <dfPanel>();
        _dialog     = GameObject.Find("Dialog").GetComponent <DialogShow>();
        BattleButton.Disable();
        //   _panel.transform.Find("NewBrainButton").GetComponent<dfButton>().Click += button_Click;

        var q = new ParseQuery <Brain>().WhereEqualTo("userId", ParseUser.CurrentUser.ObjectId).OrderBy("createdAt");

        q.FindAsync().ContinueWith(t =>
        {
            IEnumerable <Brain> result = t.Result;
            //     Dictionary<string, Brain> allBrains = new Dictionary<string, Brain>();

            foreach (Brain brain in result)
            {
                if (brain.Population != null)
                {
                    print("FILE: " + brain.Population.Name + ", URL: " + brain.Population.Url);

                    //  StartCoroutine(WaitForRequest(brain));
                }
                if (brain.ParentId != null)
                {
                    result.Where(b => b.ObjectId == brain.ParentId).First().Children.Add(brain);
                }
                else
                {
                    rootBrains.Add(brain);
                }
            }
            allBrains = result;

            DataLoaded = true;
        });

        GameObject.Find("Back Button").GetComponent <dfButton>().Click += AddBrainButtons_Click;

        slot1      = GameObject.Find("Slot 1").GetComponent <dfPanel>();
        slot1Color = slot1.BackgroundColor;
        slot2      = GameObject.Find("Slot 2").GetComponent <dfPanel>();
        slot2Color = slot2.BackgroundColor;
        slot3      = GameObject.Find("Slot 3").GetComponent <dfPanel>();
        slot3Color = slot3.BackgroundColor;
        slot4      = GameObject.Find("Slot 4").GetComponent <dfPanel>();
        slot4Color = slot4.BackgroundColor;


        slot1.DragDrop  += slot1_DragDrop;
        slot1.DragEnter += slot1_DragEnter;
        slot1.DragLeave += slot1_DragLeave;

        slot2.DragDrop  += slot1_DragDrop;
        slot2.DragEnter += slot1_DragEnter;
        slot2.DragLeave += slot1_DragLeave;

        slot3.DragDrop  += slot1_DragDrop;
        slot3.DragEnter += slot1_DragEnter;
        slot3.DragLeave += slot1_DragLeave;

        slot4.DragDrop  += slot1_DragDrop;
        slot4.DragEnter += slot1_DragEnter;
        slot4.DragLeave += slot1_DragLeave;

        BlankBrainButton.Click += new MouseEventHandler(BlankBrainButton_Click);
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        if (Settings.Brain == null)
        {
            Settings.Brain = new Brain();
        }
        if (Settings.Brain.Population != null)
        {
            TrainButton.Disable();
            StartCoroutine(WaitForRequest(Settings.Brain, true));
        }
        if (Settings.Brain.ChampionGene != null)
        {
            TrainButton.Disable();
            StartCoroutine(WaitForRequest(Settings.Brain, false));
        }
        //   if (!Settings.IsNewBrain && Settings.Brain.Name != null && Settings.Brain.Name.Length > 0)
        {
            NameTextbox.Text = Settings.Brain.Name;
        }
        //     if (!Settings.IsNewBrain && Settings.Brain.Description != null && Settings.Brain.Description.Length > 0)
        {
            DescriptionTextBox.Text = Settings.Brain.Description;
        }

        GameObject.Find("s_DistanceToKeep").GetComponent <dfSlider>().Value = Settings.Brain.DistanceToKeep;
        GameObject.Find("s_KeepDistance").GetComponent <dfSlider>().Value   = Settings.Brain.KeepDistance;

        GameObject.Find("s_FaceTarget").GetComponent <dfSlider>().Value         = Settings.Brain.FaceTarget;
        GameObject.Find("s_TurretFaceTarget").GetComponent <dfSlider>().Value   = Settings.Brain.TurretFaceTarget;
        GameObject.Find("s_MeleeAttacks").GetComponent <dfSlider>().Value       = Settings.Brain.MeleeAttacks;
        GameObject.Find("s_MeleeHits").GetComponent <dfSlider>().Value          = Settings.Brain.MeleeHits;
        GameObject.Find("s_MeleePrecision").GetComponent <dfSlider>().Value     = Settings.Brain.MeleePrecision;
        GameObject.Find("s_RifleAttacks").GetComponent <dfSlider>().Value       = Settings.Brain.RifleAttacks;
        GameObject.Find("s_RifleHits").GetComponent <dfSlider>().Value          = Settings.Brain.RifleHits;
        GameObject.Find("s_RiflePrecision").GetComponent <dfSlider>().Value     = Settings.Brain.RiflePrecision;
        GameObject.Find("s_MortarAttacks").GetComponent <dfSlider>().Value      = Settings.Brain.MortarAttacks;
        GameObject.Find("s_MortarHits").GetComponent <dfSlider>().Value         = Settings.Brain.MortarHits;
        GameObject.Find("s_MortarPrecision").GetComponent <dfSlider>().Value    = Settings.Brain.MortarPrecision;
        GameObject.Find("s_MortarDamagePerHit").GetComponent <dfSlider>().Value = Settings.Brain.MortarDamagePerHit;
        GameObject.Find("s_MortarDamagePerHit").GetComponent <dfSlider>().PerformLayout();

        // Simple fitness values
        //GameObject.Find("SMovement Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SMovement;
        //GameObject.Find("SDistance Slider").GetComponent<dfSlider>().Value = Settings.Brain.SDistance;
        //GameObject.Find("SMelee Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SMelee;
        //GameObject.Find("SRifle Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SRifle;
        //GameObject.Find("SMortar Checkbox").GetComponent<dfCheckbox>().IsChecked = Settings.Brain.SMortar;

        dfDropdown dropdown = GameObject.Find("Target Movement Dropdown").GetComponent <dfDropdown>();

        int index = 0;

        dropdown.SelectedIndex = index;
        for (index = 0; index < dropdown.Items.Length; index++)
        {
            if (dropdown.Items[index].Equals(Settings.Brain.TargetBehaviorMovement))
            {
                dropdown.SelectedIndex = index;
                break;
            }
        }

        switch (Settings.Brain.FitnessMode)
        {
        case Brain.SIMPLE:
            TabStrip.SelectedIndex = 0;
            break;

        case Brain.ADVANCED:
            TabStrip.SelectedIndex = 1;
            break;

        case Brain.BATTLE:
            TabStrip.SelectedIndex = 2;
            break;
        }

        dfSlider slider   = GameObject.Find("Speed Slider").GetComponent <dfSlider>();
        int      evoSpeed = PlayerPrefs.GetInt("Evolution Speed");

        if (evoSpeed >= 6 && evoSpeed <= 10)
        {
            slider.Value = evoSpeed - 6;
        }
        else
        {
            slider.Value = 2;
        }
    }