Beispiel #1
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            ExternalFunctionality.Toggle(ref OnGetting);
            yield return(new WaitUntil(() => Input.GetKeyUp(Basic)));

            yield return(new WaitUntil(() =>
            {
                foreach (GameObject i in Camera.main.GetComponent <main>().rounds)
                {
                    i.GetComponentInChildren <Renderer>().material.color = Color.white;
                }
                Ray point = Camera.main.ScreenPointToRay(ExternalFunctionality.MousePosition());
                RaycastHit raycastHit;
                if (Physics.Raycast(point, out raycastHit) && raycastHit.transform.GetComponent <Controller>())
                {
                    raycastHit.transform.GetComponentInChildren <Renderer>().material.color = new Color(0.8f, 0.8f, 1.0f);
                    if (Input.GetKeyDown(Basic))
                    {
                        selected = raycastHit.transform.gameObject;
                        return true;
                    }
                }
                return false;
            }));

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
            Activate(gameObject);
            ExternalFunctionality.Toggle(ref OnGetting);
            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #2
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            ExternalFunctionality.Toggle(ref OnGetting);
            yield return(new WaitUntil(delegate()
            {
                return Input.mousePosition == oldPos ? false : true;
            }));

            yield return(new WaitForSecondsRealtime(0.2f));

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
            Ray        ray = Camera.main.ScreenPointToRay(ExternalFunctionality.MousePosition());
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject == area)
                {
                    pos = hit.point + Vector3.down * 0.05f;
                    Activate(gameObject);
                    yield return(new WaitForSeconds(1f));
                }
                else
                {
                    pos = area.GetComponent <Collider>().ClosestPointOnBounds(hit.point) + Vector3.down * 0.05f;
                    Activate(gameObject);
                    yield return(new WaitForSeconds(1f));
                }
            }

            ExternalFunctionality.Toggle(ref OnGetting);
            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #3
0
 public void Click()
 {
     if (ExternalFunctionality.MessageBox(IntPtr.Zero, "Are you sure to download update? ", "Confirm", 1) == 1)
     {
         Application.OpenURL(@"https://raw.githubusercontent.com/LAWArthur/PenWar/master/Releases/setup.exe");
     }
 }
Beispiel #4
0
 public override bool OnUsing(GameObject gameObject)
 {
     if (AIUsageWeight == 0)
     {
         if (Input.GetKey(Key) && Input.GetKey(Basic))
         {
             oldPos           = ExternalFunctionality.MousePosition();
             Cursor.lockState = CursorLockMode.None;
             Cursor.visible   = true;
             Cursor.SetCursor(CursorIcon, Vector2.zero, CursorMode.Auto);
             return(true);
         }
     }
     else if (Mathf.FloorToInt(Random.value * AIUsageWeight) == 0)
     {
         foreach (GameObject i in Camera.main.GetComponent <main>().rounds)
         {
             if (i != gameObject)
             {
                 if (i.transform.position.y > gameObject.transform.position.y)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Beispiel #5
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            ExternalFunctionality.Toggle(ref OnGetting);
            yield return(new WaitUntil(() => Input.GetKeyUp(Basic)));

            Activate(gameObject);

            ExternalFunctionality.Toggle(ref OnGetting);
            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #6
0
    public void Click()
    {
        #region System.Windows.Form Implement:Off
        //DialogResult result = MessageBox.Show("你确定要删除所有存储信息吗?\n这会导致游戏数据清零", "确认信息", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
        //if (result == DialogResult.Yes)
        //{
        //    PlayerPrefs.DeleteAll();
        //}
        #endregion

        if (ExternalFunctionality.MessageBox(IntPtr.Zero, "\u4f60\u786e\u5b9a\u8981\u6e05\u7a7a\u6240\u6709\u5b58\u50a8\u5417", "\u64cd\u4f5c\u786e\u8ba4", 1) == 1)
        {
            PlayerPrefs.DeleteAll();
        }
    }
Beispiel #7
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            ExternalFunctionality.Toggle(ref OnGetting);
            yield return(new WaitUntil(delegate()
            {
                return Input.GetKey(Basic) ? false : true;
            }));

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
            ExternalFunctionality.Toggle(ref OnGetting);
            Activate(gameObject);
            yield return(new WaitForSeconds(1f));

            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #8
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            yield return(new WaitUntil(delegate()
            {
                return oldPos == ExternalFunctionality.MousePosition() ? false : true;
            }));

            yield return(new WaitForSecondsRealtime(0.2f));

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;

            force = new Vector3((ExternalFunctionality.MousePosition() - oldPos).x, 0f, (ExternalFunctionality.MousePosition() - oldPos).y) * Sensitivity;
            Activate(gameObject);
            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #9
0
    // Use this for initialization
    protected virtual void Start()
    {
        AnalyticsEvent.GameStart(new Dictionary <string, object> {
            { "player", PlayerPrefs.GetString("Settings.Name", "玩家") }
        });
        scaleSensitivity = (float)PlayerPrefs.GetInt("Settings.ScaleSensitivity") / 500;
        #region Init variable
        gaming = false;
        pens   = new List <GameObject>();
        pens.Add(Instantiate(GameObject.Find("Global").GetComponent <Global>().peninsp.Peek(), new Vector3(Random.Range(-0.7f, 0.7f), 1f, Random.Range(-0.7f, 0.7f)), Random.rotation));
        for (int i = 1; i < numPlayer; i++)
        {
            pens.Add(Instantiate(GameObject.Find("Global").GetComponent <Global>().pens[Random.Range(0, GameObject.Find("Global").GetComponent <Global>().pens.Count)], new Vector3(Random.Range(-0.7f, 0.7f), 1f, Random.Range(-0.7f, 0.7f)), Random.rotation));
        }
        rounds          = new Queue <GameObject>(pens);
        Physics.gravity = new Vector3(0f, -9.81f, 0f);
        #endregion

        #region init controller
        foreach (GameObject i in pens)
        {
            i.name = ExternalFunctionality.GenID(6);
            if (pens.IndexOf(i) == 0)
            {
                i.AddComponent <Player>();
                i.tag  = "Local";
                i.name = PlayerPrefs.GetString("Settings.Name", "玩家");
            }
            else
            {
                i.AddComponent <AI>();
            }
        }
        #endregion

        Invoke("StartGame", 3f);

        abilityInfo = GameObject.Find("AbilityInfo");
        abilityInfo.SetActive(false);

        GameObject.Find("Channel").GetComponent <Text>().text = "游戏即将开始";

        #region Set Cursor
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
        #endregion
    }
Beispiel #10
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            ExternalFunctionality.Toggle(ref OnGetting);
            yield return(new WaitUntil(() => Input.GetKeyUp(Basic)));

            yield return(new WaitUntil(() => Input.GetKeyDown(Basic)));

            yield return(new WaitUntil(delegate()
            {
                return oldPos == ExternalFunctionality.MousePosition() ? false : true;
            }));

            float st = Time.time;

            yield return(new WaitUntil(() =>
            {
                if (Time.time - st >= 1f)
                {
                    return true;
                }
                Ray point = Camera.main.ScreenPointToRay(ExternalFunctionality.MousePosition());
                RaycastHit raycastHit;
                if (!Physics.Raycast(point, out raycastHit))
                {
                    return true;
                }
                if (raycastHit.transform.gameObject.GetComponent <ParticleSystem>())
                {
                    return false;
                }
                if (raycastHit.transform.parent?.name == "Table")
                {
                    GameObject spark = Object.Instantiate(Resources.Load <GameObject>("Prefabs/Particles/Spark"), raycastHit.point + 0.02f * Vector3.up, Quaternion.identity, GameObject.Find("/Table/Spawnspace").transform);
                    gameObject.GetComponent <Controller>().productsDock.Add(new Products.SparkProduct(spark, gameObject, Level));
                    return false;
                }
                return true;
            }));

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;

            ExternalFunctionality.Toggle(ref OnGetting);
            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #11
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            yield return(new WaitUntil(delegate()
            {
                return oldPos == ExternalFunctionality.MousePosition() ? false : true;
            }));

            yield return(new WaitForSecondsRealtime(0.2f));

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;

            torque = Vector3.up * 50000f;
            Debug.Log(torque);
            Debug.DrawRay(gameObject.transform.position, torque, Color.red, 1000f);
            Activate(gameObject);
            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #12
0
 public override bool OnUsing(GameObject gameObject)
 {
     if (AIUsageWeight == 0)
     {
         if (Input.GetKey(Key))
         {
             oldPos           = ExternalFunctionality.MousePosition();
             Cursor.lockState = CursorLockMode.None;
             Cursor.visible   = true;
             Cursor.SetCursor(CursorIcon, Vector2.zero, CursorMode.Auto);
             return(true);
         }
     }
     else if (Mathf.FloorToInt(Random.value * AIUsageWeight) == 0)
     {
         return(true);
     }
     return(false);
 }
Beispiel #13
0
 public override bool OnUsing(GameObject gameObject)
 {
     if (AIUsageWeight == 0)
     {
         if (Status == AbilityStatus.Ready && Input.GetKey(Key) && Input.GetKey(Basic))
         {
             oldPos    = ExternalFunctionality.MousePosition();
             Status    = AbilityStatus.Cooling;
             StateTemp = CoolTemp;
             return(true);
         }
     }
     else if (Mathf.FloorToInt(Random.value * AIUsageWeight) == 0 && Status == AbilityStatus.Ready && Physics.OverlapSphere(gameObject.transform.position, 0.8f + 0.2f * Level).Length > 1)
     {
         Status    = AbilityStatus.Cooling;
         StateTemp = CoolTemp;
         return(true);
     }
     return(false);
 }
Beispiel #14
0
        public override IEnumerator Coroutine(GameObject gameObject)
        {
            ExternalFunctionality.Toggle(ref OnGetting);
            yield return(new WaitUntil(delegate()
            {
                return oldPos == Input.mousePosition ? false : true;
            }));

            yield return(new WaitForSecondsRealtime(0.2f));

            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
            Ray        ray = Camera.main.ScreenPointToRay(ExternalFunctionality.MousePosition());
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject == area)
                {
                    pos = hit.point + Vector3.down * 0.05f;
                }
                else
                {
                    pos = area.GetComponent <Collider>().ClosestPointOnBounds(hit.point) + Vector3.down * 0.05f;
                }
                Object.Destroy(area);
                mountain = GameObject.Instantiate(Resources.Load <GameObject>("Prefabs/Mountain"), pos + Vector3.down * 0.6f, Quaternion.identity);
                gameObject.GetComponent <Controller>().productsDock.Add(new Products.Mountain(mountain, gameObject, Level));
                for (int i = 0; i < 6; i++)
                {
                    Activate(gameObject);
                    yield return(new WaitForSeconds(0.1f));
                }

                yield return(new WaitForSeconds(1f));
            }

            ExternalFunctionality.Toggle(ref OnGetting);
            gameObject.GetComponent <Controller>().StartCoroutine(gameObject.GetComponent <Controller>().Coroutine());
        }
Beispiel #15
0
 public override void OnActivated(GameObject gameObject)
 {
     if (OnGetting)
     {
         Shared.SpectPoint = gameObject.transform.position + Vector3.up * 2;
         linear.GetComponent <RectTransform>().localRotation = Quaternion.Euler(Vector3.forward * Mathf.Rad2Deg * Mathf.Atan2(ExternalFunctionality.MousePosition().y - linear.transform.position.y, ExternalFunctionality.MousePosition().x - linear.transform.position.x) + new Vector3(0f, 0f, -90f));
     }
     else
     {
         Shared.SpectPoint = gameObject.transform.position + Vector3.up;
     }
 }