示例#1
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < WIDTH; ++i)
        {
            if (map[i, HEIGHT - 1] == null)
            {
                map[i, HEIGHT - 1] = Instantiate(prefab, new Vector3(i, 0, 0), Quaternion.identity) as GameObject;
                Candy candy = map[i, HEIGHT - 1].GetComponent <Candy>();

                ECandyType type = GenerateCandyType();
                candy.SetType(type);
            }
        }

        for (int i = 0; i < HEIGHT; ++i)
        {
            for (int j = 0; j < WIDTH; ++j)
            {
                if (map[j, i] == null)
                {
                    map[j, i]     = map[j, i + 1];
                    map[j, i + 1] = null;

                    if (map[j, i] != null)
                    {
                        map[j, i].transform.position = new Vector3(j, i, 0);
                    }
                }
            }
        }
    }
示例#2
0
 private void CheckToClickCandy()
 {
     if (InputManager.TouchStart() && !this.isClicked)
     {
         Ray          ray    = InputManager.GetTouchPointRay();
         RaycastHit2D rayHit = Physics2D.Raycast(ray.origin, ray.direction, 15.0f, 1 << LayerMask.NameToLayer("Candy"));
         if (rayHit)
         {
             CandyController candy = rayHit.transform.gameObject.GetComponent <CandyController>();
             this.selectedCandyType = candy.Type;
             AddSelectedCandy(candy);
             this.comboFont.OnLink(1, candy.transform.position);
             Sound.SoundManager.Instance.PlayEffectSound(Sound.EEffectSoundType.LinkCandy);
         }
         this.isClicked = true;
     }
     else if (InputManager.Touching() && this.isClicked)
     {
         if (this.selectedCandy.Count == 0)
         {
             return;
         }
         Ray          ray    = InputManager.GetTouchPointRay();
         RaycastHit2D rayHit = Physics2D.Raycast(ray.origin, ray.direction, 15.0f, 1 << LayerMask.NameToLayer("Candy"));
         if (rayHit)
         {
             if (this.selectedCandy.Last().gameObject != rayHit.transform.gameObject)
             {
                 if (this.selectedCandy.Count > 1 &&
                     this.selectedCandy.SecondLast().gameObject == rayHit.transform.gameObject)
                 {
                     RemoveLastSelectedCandy();
                     this.comboFont.OnLink(this.selectedCandy.Count, this.selectedCandy.Last().transform.position);
                     Sound.SoundManager.Instance.PlayEffectSound(Sound.EEffectSoundType.DelinkCandy);
                 }
                 else
                 {
                     CandyController candy = rayHit.transform.gameObject.GetComponent <CandyController>();
                     if (!candy.Selected && candy.Type == this.selectedCandyType &&
                         MAX_RANGE_FOR_SELECT > Vector2.Distance(this.selectedCandy.Last().transform.position, candy.transform.position))
                     {
                         AddSelectedCandy(candy);
                         this.comboFont.OnLink(this.selectedCandy.Count, candy.transform.position);
                         Sound.SoundManager.Instance.PlayEffectSound(Sound.EEffectSoundType.LinkCandy);
                     }
                 }
             }
         }
     }
     else if (InputManager.TouchEnd())
     {
         this.isClicked = false;
         PangCandies();
     }
 }
示例#3
0
        public void UseEquipedCandySkill(ECandyType _type)
        {
            this.selectedCandy.Clear();
            for (int i = 0; i < this.candyList.Count; ++i)
            {
                if (this.candyList[i].Type == _type)
                {
                    this.selectedCandy.Add(this.candyList[i]);
                }
            }

            this.isClicked = false;
            PangCandies();
        }
示例#4
0
文件: Candy.cs 项目: avildes/candies
        internal void SetType(ECandyType type)
        {
            this.type = type;
            switch (type)
            {
            case ECandyType.BLACK:
                sptRenderer.color = Color.black;
                break;

            case ECandyType.GREEN:
                sptRenderer.color = Color.green;
                break;

            case ECandyType.MAGENTA:
                sptRenderer.color = Color.magenta;
                break;

            case ECandyType.WHITE:
                sptRenderer.color = Color.white;
                break;
            }
        }
示例#5
0
 public void SetEquipCandy(ECandyType _type)
 {
     GameController.Instance.EquipedCandy = _type;
     this.equipedCandy.sprite             = Util.SpriteFactory.Instance.GetSprite("Default", _type.ToString());
 }
示例#6
0
 public void SetEquipedCandy(ECandyType _type)
 {
     this.equipCandy.SetEquipCandy(_type);
 }
示例#7
0
 public void SetCandyType(ECandyType _type)
 {
     this.type = _type;
 }
示例#8
0
 public void SetEquipedCandy(ECandyType _type)
 {
     this.equipedCandyType = _type;
     this.candy.sprite     = Test.Util.SpriteFactory.Instance.GetSprite("Default", _type.ToString());
 }
示例#9
0
 public void SetType(ECandyType _type)
 {
     this.Type = _type;
     this.mySpriteRenderer.sprite = Util.SpriteFactory.Instance.GetSprite("Default", this.Type.ToString());
 }