Beispiel #1
0
 private void toolStripButton_clear_Click(object sender, EventArgs e)
 {
     if (ActiveBox != null)
     {
         CFuncNode node = ActiveBox.LinkObj as CFuncNode;
         if (node != null)
         {
             IMonitorConfig config = node.ExtConfigObj as IMonitorConfig;
             if (config != null)
             {
                 ActiveBox.ClearAlarms();
                 RefreshInfo();
             }
             else
             {
                 IConfigManager <IMonitorType> monitorType = node.ExtConfigObj as IConfigManager <IMonitorType>;
                 if (monitorType != null)
                 {
                     ActiveBox.ClearAlarms();
                     RefreshInfo();
                 }
             }
         }
     }
 }
Beispiel #2
0
 private void toolStripButton_preview_Click(object sender, EventArgs e)
 {
     if (ActiveBox != null)
     {
         CFuncNode node = ActiveBox.LinkObj as CFuncNode;
         if (node != null)
         {
             IVisionMonitorConfig config = node.ExtConfigObj as IVisionMonitorConfig;
             if (config != null)
             {
                 ActiveBox.Preview();
             }
         }
     }
 }
Beispiel #3
0
    void CheckMouseDown()
    {
        if (Input.GetMouseButtonDown(0))
        {
            cannon = null;
            float          dis;
            float          dis2    = 10;
            RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f);
            for (int i = 0; i < hitInfo.Length; i++)
            {
                if (paused == false)
                {
                    if (hitInfo[i].collider.gameObject.name == "OptionsButton")
                    {
                        paused = true;
                        UnityEngine.Object[] objects = FindObjectsOfType(typeof(GameObject));
                        foreach (GameObject go in objects)
                        {
                            go.SendMessage("OnPauseGame", SendMessageOptions.DontRequireReceiver);
                        }
                        options = true;
                        GameObject instance = Instantiate(Resources.Load("OptionsMenu", typeof(GameObject))) as GameObject;

                        OptionsMenu om = instance.GetComponent <OptionsMenu>();
                        om.mouseCheck = this.gameObject;
                        return;
                    }

                    if (hitInfo[i].collider.gameObject.tag == "hitTest")
                    {
                        dis = Vector2.Distance(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), new Vector2(hitInfo[i].collider.gameObject.transform.parent.transform.position.x, hitInfo[i].collider.gameObject.transform.parent.transform.position.y));
                        if (dis < dis2)
                        {
                            dis2   = dis;
                            cannon = hitInfo[i].collider.gameObject.GetComponentInParent <Cannon>();
                        }
                    }
                    else if (hitInfo[i].collider.gameObject.tag == "WeaponIcon")
                    {
                        WeaponIcon icon = hitInfo[i].collider.gameObject.GetComponent <WeaponIcon>();
                        if (icon.type != "Platform")
                        {
                            if (energy.energy >= icon.cost)
                            {
                                GameObject instance = Instantiate(Resources.Load(icon.type, typeof(GameObject))) as GameObject;
                                cannon      = instance.GetComponent <Cannon>();
                                cannon.type = icon.type;
                                cannon.Drag(false);
                                cannon.cost = icon.cost;
                                return;
                            }
                            else
                            {
                                infoText.color = new Color(infoText.color.r, infoText.color.g, infoText.color.b, 1f);
                            }
                        }
                        else
                        {
                            if (energy.energy >= icon.cost)
                            {
                                GameObject instance = Instantiate(Resources.Load(icon.type, typeof(GameObject))) as GameObject;
                                platform = instance.GetComponent <Platform>();
                            }
                        }
                    }
                    else if (hitInfo[i].collider.gameObject.name == "GoBack")
                    {
                        SceneManager.LoadScene(2);
                        MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>();
                        mp.ChangeSong = true;
                        mp.nextSong   = 0;
                    }
                    else if (hitInfo[i].collider.gameObject.name == "RestartLevel")
                    {
                        GameObject   instance = Instantiate(Resources.Load("WeaponSelectPrefab", typeof(GameObject))) as GameObject;
                        WeaponSelect ws       = instance.gameObject.GetComponentInChildren <WeaponSelect>();
                        ws.map = false;
                        paused = true;
                    }
                }
                else
                {
                    if (hitInfo[i].collider.gameObject.name == "Go")
                    {
                        if (hitInfo[i].collider.transform.parent.FindChild("WeaponSelect").FindChild("ActiveBox1").GetComponent <ActiveBox>().Type != "Empty")
                        {
                            SceneManager.LoadScene(1);
                        }
                        else
                        {
                            hitInfo[i].collider.gameObject.transform.parent.FindChild("WeaponSelect").FindChild("NoweaponsSelected").GetComponent <Text>().color = new Color(1f, 0f, 0f, 1f);
                        }
                    }
                    else if (hitInfo[i].collider.gameObject.name == "ReturnToMap")
                    {
                        SceneManager.LoadScene(2);
                        MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>();
                        mp.ChangeSong = true;
                        mp.nextSong   = 0;
                    }
                    else
                    {
                        for (int r = 1; r < 4; r++)
                        {
                            if (hitInfo[i].collider.gameObject.name == r.ToString())
                            {
                                if (GameVar.WeaponsUnlocked[11 + r] == true)
                                {
                                    Info info = GameObject.Find("Info").GetComponent <Info>();
                                    info.ChangeInfo((byte)(12 + r));
                                }
                            }
                        }
                        string PassiveSlotName;
                        for (int r = 1; r < 13; r++)
                        {
                            PassiveSlotName = "PassiveBox" + r;
                            if (hitInfo[i].collider.gameObject.name == PassiveSlotName)
                            {
                                PassiveBox passiveBox = hitInfo[i].collider.gameObject.GetComponent <PassiveBox>();
                                passiveBox.AddWeapon();
                                if (passiveBox.Locked == false)
                                {
                                    Info info = GameObject.Find("Info").GetComponent <Info>();
                                    info.ChangeInfo((byte)passiveBox.num);
                                }
                            }
                        }
                        for (int r = 1; r < 5; r++)
                        {
                            PassiveSlotName = "ActiveBox" + r;
                            if (hitInfo[i].collider.gameObject.name == PassiveSlotName)
                            {
                                ActiveBox activeBox = hitInfo[i].collider.gameObject.GetComponent <ActiveBox>();
                                activeBox.ResetIcons();
                            }
                        }
                    }
                }
            }
            if (cannon != null)
            {
                cannon.Drag();
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            if (platform == null)
            {
                if (cannon != null)
                {
                    RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f);
                    for (int i = 0; i < hitInfo.Length; i++)
                    {
                        if (hitInfo[i].collider.gameObject.tag == "TrashCan")
                        {
                            if (cannon.emptyCannon != null)
                            {
                                energy.energy += Mathf.Round(cannon.cost * 0.66f);
                                if (cannon.type == "Battery")
                                {
                                    energy.maxEnergy *= 0.5f;
                                }
                                if (cannon.type == "Generator")
                                {
                                    energy.energyAmount -= 1;
                                }
                                energy.UpdateUI();
                            }
                            Destroy(cannon.emptyCannon, 0f);
                            Destroy(cannon.gameObject, 0f);;
                            return;
                        }
                    }


                    StartCoroutine(MouseRelease(cannon));
                }
            }
            else
            {
                platform.Drop(energy);
                platform = null;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D[] hitInfo = Physics2D.RaycastAll(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 1f);
            for (var r = 0; r < hitInfo.Length; r++)
            {
                if (hitInfo[r].collider.gameObject.name == "OptionButton")

                {
                    Map mapScript = map.GetComponent <Map>();
                    if (options == false && mapScript.active == true)
                    {
                        options = true;

                        mapScript.active = false;
                        GameObject instance = Instantiate(Resources.Load("OptionsMenu", typeof(GameObject))) as GameObject;

                        OptionsMenu om = instance.GetComponent <OptionsMenu>();
                        om.map        = true;
                        om.mouseCheck = this.gameObject;
                        return;
                    }
                }
            }
            for (var r = 0; r < hitInfo.Length; r++)
            {
                if (hitInfo[r].collider != null)
                {
                    if (hitInfo[r].collider.gameObject.name == "HitTest")
                    {
                        Map mapScript = map.GetComponent <Map>();
                        if (mapScript.active == true)
                        {
                            Planet planet = hitInfo[r].collider.gameObject.GetComponentInParent <Planet>();


                            if (planet.unlocked == true)
                            {
                                GameObject instance = Instantiate(Resources.Load("WeaponSelectPrefab", typeof(GameObject))) as GameObject;
                                mapScript.active = false;
                                GameVar gv = GameObject.Find("GameVar").GetComponent <GameVar>();
                                gv.Level      = planet.level;
                                gv.planetType = (byte)planet.planetType;
                            }
                        }
                    }
                    else if (hitInfo[r].collider.gameObject.name == "Go")
                    {
                        if (hitInfo[r].collider.transform.parent.FindChild("WeaponSelect").FindChild("ActiveBox1").GetComponent <ActiveBox>().Type != "Empty")
                        {
                            SceneManager.LoadScene(1);
                            MusicPlayer mp = GameObject.Find("MusicPlayer").GetComponent <MusicPlayer>();
                            mp.ChangeSong = true;
                            mp.nextSong   = Random.Range(1, 4);
                        }
                        else
                        {
                            hitInfo[r].collider.gameObject.transform.parent.FindChild("WeaponSelect").FindChild("NoweaponsSelected").GetComponent <Text>().color = new Color(1f, 0f, 0f, 1f);
                        }
                    }
                    else if (hitInfo[r].collider.gameObject.name == "ReturnToMap")
                    {
                        Destroy(hitInfo[r].collider.gameObject.transform.parent.gameObject);
                        Map mapScript = map.GetComponent <Map>();
                        mapScript.active = true;
                        return;
                    }
                    else if (hitInfo[r].collider.gameObject.name == "UnLockAll")
                    {
                        Map mapScript = map.GetComponent <Map>();
                        if (mapScript.active == true)
                        {
                            GameObject.Find("GameVar").GetComponent <GameVar>().UnlockAll();
                            SceneManager.LoadScene(2);
                        }
                    }
                    else
                    {
                        for (int i = 1; i < 4; i++)
                        {
                            if (hitInfo[r].collider.gameObject.name == i.ToString())
                            {
                                if (GameVar.WeaponsUnlocked[11 + i] == true)
                                {
                                    info = GameObject.Find("Info").GetComponent <Info>();
                                    info.ChangeInfo((byte)(12 + i));
                                }
                            }
                        }
                        string PassiveSlotName;
                        for (int i = 1; i < 13; i++)
                        {
                            PassiveSlotName = "PassiveBox" + i;
                            if (hitInfo[r].collider.gameObject.name == PassiveSlotName)
                            {
                                PassiveBox passiveBox = hitInfo[r].collider.gameObject.GetComponent <PassiveBox>();
                                passiveBox.AddWeapon();
                                if (passiveBox.Locked == false)
                                {
                                    info = GameObject.Find("Info").GetComponent <Info>();
                                    info.ChangeInfo((byte)passiveBox.num);
                                }
                            }
                        }
                        for (int i = 1; i < 5; i++)
                        {
                            PassiveSlotName = "ActiveBox" + i;
                            if (hitInfo[r].collider.gameObject.name == PassiveSlotName)
                            {
                                ActiveBox activeBox = hitInfo[r].collider.gameObject.GetComponent <ActiveBox>();
                                activeBox.ResetIcons();
                            }
                        }
                    }
                }
            }
        }
    }