예제 #1
0
    /// <summary>
    /// Raises the tap ground event.
    /// </summary>
    /// <param name="evt">Evt.</param>
    public void OnTapGround(CameraManager.CameraEvent evt)
    {
        //		Debug.Log ("OnTapGround");

        if (this.gameMode == Common.GameMode.NORMAL)
        {
            if (this.selectedItem != null)
            {
                BaseItemScript temp = this.selectedItem;
                this.selectedItem = null;
                temp.SetSelected(false);
            }

            //			if (this._unit == null) {
            //				this._unit = this.AddItem (5492, true);
            //				this._unit.SetState (Common.State.WALK);
            //				this._unit.SetPosition (evt.point);
            //			} else {
            //				this._unit.LookAt (evt.point);
            //			}
        }

        if (this.gameMode == Common.GameMode.ATTACK)
        {
            if (selectedUnit == 0)
            {
                if (this._swordManExpended == _swordManCount)
                {
                    return;
                }
                this._swordManExpended++;

                AttackOverlayWindowScript.instance.SwordManCounter.text = (this._swordManCount - _swordManExpended).ToString() + "x";
            }
            else if (selectedUnit == 1)
            {
                if (this._archerExpended == _archerCount)
                {
                    return;
                }
                this._archerExpended++;

                AttackOverlayWindowScript.instance.ArcherCounter.text = (this._archerCount - _archerExpended).ToString() + "x";
            }

            int[] unitIds = new int[] { _swordMan_ID, _archer_ID };

            evt.point.x = Mathf.Clamp(evt.point.x, 0, GroundManager.nodeWidth - 1);
            evt.point.z = Mathf.Clamp(evt.point.z, 0, GroundManager.nodeHeight - 1);

            this._unit = this.AddItem(unitIds[selectedUnit], true, true);
            this._unit.SetPosition(evt.point);
            this._unit.Attacker.AttackNearestTarget();
            this._unit.OnItemDestroy += this.OnUnitDied;

            SoundManager.instance.PlaySound(SoundManager.instance.Yeah, false);
        }

        //		if (testCharacter != null) {
        //			testCharacter.LookAt (_builderHutInstance);
        //		}

        //		if (this._builderInstance != null) {
        //			this._builderInstance.gameObject.SetActive (true);
        //			this._builderInstance.Walker.WalkToPosition (evt.point);
        //		}

        //		if (this._swordManInstance != null) {
        //			this._swordManInstance.gameObject.SetActive (true);
        //			this._swordManInstance.Walker.WalkToPosition (evt.point);
        //		}
    }