//private void OnTriggerEnter(Collider col)
        //{
        //    col.transform.SendMessage("Hitted", col);
        //    CustomController.HitEffect(effectGO,col.transform.position);
        //    SelfDestory();
        //}

        private void OnCollisionEnter(Collision collision)
        {
            Debug.Log(collision.transform.gameObject.name);
            collision.transform.SendMessage("Hitted", collision);
            CustomController.HitEffect(effectGO, collision.contacts[0].point);
            SelfDestory();
        }
Пример #2
0
 public void LoadTreeScene()
 {
     CustomController.SetCoin(CurrentScore);
     Debug.Log(CurrentScore);
     Debug.Log(CustomController.GetScore());
     SceneManager.LoadScene("Tree_Avatar");
 }
Пример #3
0
        //create grid
        //witht the raduis, height/width/length is meanless, specially width & length
        private void SpwanGridCreater(float width, float height, float length, float gap, float r)
        {
            var localHeight = -height;

            while (CustomController.Less(localHeight, height))
            {
                var localLength = -length;
                while (CustomController.Less(localLength, length))
                {
                    var localWidth = -width;
                    while (CustomController.Less(localWidth, width))
                    {
                        var targetPos = new Vector3(localWidth, localHeight, localLength);
                        if (CustomController.InRange(deviceGO.transform.position, targetPos, r))
                        {
                            var newGrid = new SpawnGrid(targetPos);
                            ssHandler.Subscribe(newGrid);
                        }
                        localWidth += gap;
                    }
                    localLength += gap;
                }
                localHeight += gap;
            }
        }
Пример #4
0
        public void StatusUpdate(Vector3 pos, Direction dir, SpawngridConfig conf, List <IObersver> observers)
        {
            if (!CustomController.InRange(pos, GetPos(), conf, dir))
            {
                UpdatePos(dir, conf);
                UpdateNeigbor(this, observers, conf.gap);
                this.SignNeighbor(observers, conf.gap);
                this.IsOccupy = false;
            }
            #region foldcomment
            //todo refactro code
            //var neighborPos = new Vector3(this.X,this.Y,this.Z);

            //if (neighborDic[s] == null)
            //{
            //    if (s == front)
            //    {
            //        neighborPos += Vector3.forward*gap;
            //    }
            //    else if (s == back)
            //    {
            //        neighborPos += Vector3.back * gap;
            //    }
            //    else if (s == right)
            //    {
            //        neighborPos += Vector3.right * gap;
            //    }
            //    else if (s == left)
            //    {
            //        neighborPos += Vector3.left * gap;
            //    }
            //    else if (s == up)
            //    {
            //        neighborPos += Vector3.up * gap;
            //    }
            //    else if (down == s)
            //    {
            //        neighborPos += Vector3.down * gap;
            //    }
            //    neighborDic[s] = new SpawnGrid(neighborPos);
            //    if (gm.TempSGHoder == null)
            //    {
            //        gm.TempSGHoder = new List<IObersver>();
            //        gm.TempSGHoder.Add(neighborDic[s]);
            //    }
            //    else { gm.TempSGHoder.Add(neighborDic[s]); }
            //}
            #endregion
            //force update all info
        }
Пример #5
0
        private void LateUpdate()
        {
            MoveHandler?.Invoke();
            //current scene score
            textCamPos.GetComponent <Text>().text = CurrentScore.ToString();

            List <Direction> moveDir = CustomController.PositionCompair(previousPos, currentRoundPos, sconfig.gap);

            foreach (Direction s in moveDir)
            {
                previousPos = currentRoundPos;
                ObserverUpate(s);
            }
        }
Пример #6
0
        IEnumerator Die()
        {
            if (!crRunning)
            {
                crRunning = true;
                //1s seems to fast, change it to 2
                yield return(new WaitForSeconds(2));

                //todo currently, send the value to currentscore directly
                //will send this info to coin(?), then when coin touches player, val increase.
                //GameManager.Instance.CurrentScore += BoundsVal;
                var canv = GameObject.Find("Canv");
                CustomController.SpawnCoin(gm.coin, canv, this.gameObject, BoundsVal);
                gm.MonsterDie(this.gameObject);
                Destroy(this.gameObject);
            }
            else
            {
                yield return(null);
            }
        }