Example #1
0
    public void OnDrop(PointerEventData eventData)
    {
        d = eventData.pointerDrag.GetComponent <Draggable> ();
//		GameObject GameController = GameObject.Find ("GameController");
//		GameController gameController = GameController.GetComponent<GameController> ();
//		GameObject ButtonScripts = GameObject.Find ("ButtonsCanvas");
//		ButtonScripts buttonScripts = ButtonScripts.GetComponent<ButtonScripts> ();
        buttonScripts.TurnEverythingFalse();
        GameController.control.TurnFalsePlayerButtons();


//		Debug.Log("OnDrop cone");

//		if (d != null  ) {
//			Debug.Log(d.attack);
//			attack = d.attack;
//			movementCost = d.movementCost;
//			effect = d.effect;
        d.parentToReturnTo = this.transform;

//		}
        mobility = false;
//		else{
//			Debug.Log("OnDrop cone");
//			Debug.Log(d.cardType);
        switch (d.cardType)
        {
        case CardTypes.Damage:

//				GameObject Unit = GameObject.Find(map.selecterPlayer);
//				Unit unit = Unit.GetComponent<Unit> ();
            DamageCard damageCard = d.GetComponentInParent <DamageCard>();
//				DamageCard damageCard = eventData.pointerDrag.GetComponent<DamageCard>();
            Debug.Log(damageCard.DamageType);
            mobility   = damageCard.Mobility;
            range      = damageCard.Range;
            target     = damageCard.Target;
            areaRange  = damageCard.Area;
            damageType = damageCard.DamageType;
            GameController.control.cardCost = damageCard.CardCost;

            DamageType();

            effect = damageCard.Effect;
            RunTargets();
            break;

        case CardTypes.Heal:
            HealCard          healCard = d.GetComponentInParent <HealCard>();
            GameObject        Player   = GameObject.Find(map.selecterPlayer);
            PlayableCharacter player   = Player.GetComponent <PlayableCharacter> ();
//				DamageCard damageCard = eventData.pointerDrag.GetComponent<DamageCard>();
//				mobility = damageCard.Mobility;
//				buttonScripts.healSelected = true;
//				playingPlayer = map.selecterPlayer;
            range     = healCard.Range;
            target    = healCard.Target;
            areaRange = healCard.Area;
            effect    = healCard.Effect;
            healDot   = player.PlayerClass.HealValue / 2;
            heal      = (player.PlayerClass.HealValue * healCard.CardHeal) / 3;
            GameController.control.cardCost = healCard.CardCost;
            RunTargets();
            break;

        case CardTypes.Utility:
            UtilityCard utilityCard = d.GetComponentInParent <UtilityCard>();
//				DamageCard damageCard = eventData.pointerDrag.GetComponent<DamageCard>();
//				mobility = damageCard.Mobility;
            range     = utilityCard.Range;
            target    = utilityCard.Target;
            areaRange = utilityCard.Area;
            effect    = utilityCard.Effect;
            GameController.control.cardCost = utilityCard.CardCost;
            RunTargets();
            break;

        default:
            break;
        }

//		}
        //TODO värjää väärin
        if (d != null)
        {
            GameObject     HighlightTiles = GameObject.Find("_Scripts");
            HighlightTiles highlightTiles = HighlightTiles.GetComponent <HighlightTiles> ();
            highlightTiles.HighlightTilesInRange();
        }
    }