Ejemplo n.º 1
0
    public override SkillEffectResponse apply(Creature from, int dice1, int dice2)
    {
        // Calculate damage, and apply buffs
        SkillEffectResponse response = new SkillEffectResponse();

        //response.type = type;
        //response.color = MyColor.FireballColor;
        response.proficient = new List <int>();

        // change: + means recovery, - means damage/cost
        response.effects = new List <SingleEffectResponse>();
        response.effects.Add(new SingleEffectResponse());
        response.effects [0].stage      = 0;
        response.effects [0].total      = 1;
        response.effects [0].type       = type;
        response.effects [0].delay      = 0.2f;
        response.effects [0].prefabPath = "Prefab/Fireball/fireball_prefab";
//		response.effects [0].opponent_buff_on = new List<Buff> ();
//		response.effects [0].opponent_buff_on.Add (new BuffAmplifyDamage ());
//		response.effects [0].opponent_buff_on.Add (new BuffAmplifyDamage ());
        //response.opponent_hp_change = new List<int>();
        //response.self_mp_change = new List<int>();

        float damage   = -(Dice.max(dice1, dice2) + 3) * from.detail.final_mag * from.detail.do_damage_total * from.detail.do_damage_magical;
        int   manacost = -(int)((float)cost * from.detail.cost_coefficient);

        if (proficient >= 1 && dice2 > dice1)
        {
            damage *= 1.5f;
            response.proficient.Add(0);
        }

        //response.opponent_hp_change.Add((int)damage);
        response.effects[0].opponent_hp_change = ((int)damage);

        if (proficient >= 2 && dice2 > dice1 * 2)
        {
            manacost = 0;
            response.proficient.Add(1);
        }

        response.effects [0].self_mp_change = manacost;

        if (dice2 > dice1 * 3)
        {
            response.effects [0].total++;
            response.effects.Add(new SingleEffectResponse(response.effects[0]));
            response.proficient.Add(2);
        }

        //response.self_mp_change.Add(manacost);

        from.detail.cur_mp += manacost;

        // Apply all effect to target
        //to.takeDamage(response);
        // no need to calculate counter attack

        return(response);
    }
Ejemplo n.º 2
0
    public override SkillEffectResponse apply(Creature from, int dice1, int dice2)
    {
        SkillEffectResponse response = new SkillEffectResponse();

        response.proficient = new List <int>();


        return(response);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        switch (turnState)
        {
        case Turn.HERO:
        {
            switch (state)
            {
            case State.VICTORY:
            {
                return;
            }

            case State.DEFEATED:
            {
                return;
            }

            case State.STATE_DICE_1:
            {
                // random dice 1
                // init animation and play
                // random a value
                //dice1 = Random.Range(1, 7);
                dice1 = 1;
                // reset position
                dice1_obj.GetComponent <RectTransform>().anchoredPosition = dice1_pos + new Vector2(Random.Range(-30, 31), Random.Range(-30, 31));
                // set active
                dice1_obj.SetActive(true);
                // set value
                dice1_obj.GetComponent <DiceRoll>().diceValue = dice1;
                // play animation
                dice1_obj.GetComponent <Animation>().Play("Dice");

                // turn +1
                Hturn++;
                heroTurn.text = "HTurn : " + Hturn.ToString();

                state = State.STATE_WAIT;
                return;
            }

            case State.STATE_SKILL:
            {
                // player select skill in gui
                scroll.applyBtn.enabled = true;

                state = State.STATE_WAIT;
                return;
            }

            case State.STATE_SKILL_APPLY:
            {
                //createScrollingText (new Vector2 (-467.5f, 170.0f), scroll.selectedSkill.name, MyColor.SkillColor
                //	, 0.1f, 1.2f, this, State.STATE_DICE_2);
                dispalySkillTexts(true, scroll.selectedSkill.name, 0.1f, 1.2f, this);

                GameObject prefab = Resources.Load <GameObject> (scroll.selectedSkill.preparePath);

                GameObject obj = Instantiate(prefab, canvas.transform);
                obj.name = "__PREPARE__";
                prefab   = null;
                obj      = null;

                //hero_buff_list.takeTurn ();
                //hero_buff_list.addBuff (new BuffAmplifyDamage ());

                state = State.STATE_WAIT;
                return;
            }

            case State.STATE_DICE_2:
            {
                // random dice 2
                // init animation and play
                // random a value
                //dice2 = Random.Range(1, 7);
                dice2 = 6;
                // reset position
                dice2_obj.GetComponent <RectTransform>().anchoredPosition = dice2_pos + new Vector2(Random.Range(-30, 31), Random.Range(-30, 31));
                // set active
                dice2_obj.SetActive(true);
                // set value
                dice2_obj.GetComponent <DiceRoll>().diceValue = dice2;
                // play animation
                dice2_obj.GetComponent <Animation>().Play("Dice");

                // apply skill
                response = scroll.selectedSkill.apply(hero, dice1, dice2);
                // opponent take damage
                //counter = monster.takeDamage(response);
                // apply counter
                //hero.takeCounterEffect(counter);
                // till now, response and counter are ready to display

                // 显示精通文本
                //displayProficientTexts (true);

                // change hp and mp in gui
                //hero_mp.text = hero.mp.ToString();
                //float h = hero_hp_bar.sizeDelta.y;
                //hero_mp_bar.sizeDelta = new Vector2(((float)hero.mp) / ((float)hero.maxMp) * 233.0f, h);

                state = State.STATE_WAIT;
                return;
            }

            case State.STATE_PROFICIENT:
            {
                //float delay =
                displayProficientTexts(true);
                //if (delay == 0.0f)
                state = State.STATE_SKILL_ANI;
                //else
                //state = State.STATE_WAIT;
                return;
            }

            case State.STATE_SKILL_ANI:
            {
                // change hp and mp in gui
                //hero_mp.text = hero.mp.ToString();
                //float h = hero_hp_bar.sizeDelta.y;
                //hero_mp_bar.sizeDelta = new Vector2(((float)hero.mp) / ((float)hero.maxMp) * 233.0f, h);
                hero_manager.UpdateManually();
                generateSkillEffect();

                //effect_prefab = null;

                state = State.STATE_WAIT;
                //state = State.STATE_EFFECT;
                return;
            }

            case State.STATE_JUDGEMENT:
            {
                state = State.STATE_WAIT_TURN_FINISH;
                return;
            }

            case State.STATE_WAIT_TURN_FINISH:
            {
                if (canvas.transform.childCount == 0)
                {
                    dice1_obj.SetActive(false);
                    dice2_obj.SetActive(false);
                    response.Clear();
                    state = State.STATE_DICE_1;
                }
                return;
            }
//                    case State.ADD_BUFF:
//                    {
//                        // add some buff according to skilleffectresponse
//
//                        state = State.PREPARE_DAMAGE_ANI;
//                        return;
//                    }
//                    case State.PREPARE_DAMAGE_ANI:
//                    {
//						float time = 0.1f;
//                        // init animation with damage and play
//						for (int i=0;i<response.damage.Count;i++)
//						{
//							time += i * 0.12f;
//							// blink attack
//							delayCreateBlinkAttack(MyColor.FireballColor, false, time);
//
//							// damage floating text
//							delayCreateFloatingText(false, "-"+response.damage[i].ToString(), MyColor.HpColor, time);
//
//							// target shaking
//							monster_obj.GetComponent<Animation>().Play("Shake");
//
//							// hp decrease
//							delayHPMPDecrease(monster_bar, monster_hp, response.hp[i], monster.maxHp, time);
//						}
//
//						// counterattack
//						if (response.counterattack != null) {
//							for (int i = 0; i < response.counterattack.Count; i++) {
//								time += (i + 1) * 0.12f;
//								// blink counterattack
//								delayCreateBlinkAttack (MyColor.CounterAttackColor, true, time);
//
//								// counterattack floating text
//								delayCreateFloatingText (true, "-" + response.counterattack [i].ToString (), MyColor.HpColor, time);
//
//								// target shaking
//								hero_obj.GetComponent<Animation> ().Play ("Shake");
//
//								// hp decrease
//								delayHPMPDecrease (hero_hp_bar, hero_hp, response.counterhp [i], hero.maxHp, time);
//							}
//						}
//
//						StartCoroutine(DelayToInvoke.DelayToInvokeDo(
//							()=>{
//								state = State.JUDGEMENT;
//							}, time + 0.15f));
//
//                        state = State.ING_DAMAGE_ANI;
//                        return;
//                    }
//                    case State.ING_DAMAGE_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//                        //state = State.JUDGEMENT;
//                        return;
//                    }
//                    case State.JUDGEMENT:
//                    {
//                        // before judge
//
//                        // judge if some one win
//
//                        state = State.BUFF_COUNT;
//                        return;
//                    }
//                    case State.BUFF_COUNT:
//                    {
//						// all turns of buff minus 1
//
//                        state = State.PREPARE_TURN_END_ANI;
//                        return;
//                    }
//                    case State.PREPARE_TURN_END_ANI:
//                    {
//						// prepare turn ending animation and play
//
//                        state = State.ING_TURN_END_ANI;
//                        return;
//                    }
//                    case State.ING_TURN_END_ANI:
//                    {
//                        // do nothing
//						// animation finish event will call
//
//                        // new turn with monster
//                        turnState = Turn.MONSTER;
//						state = State.PREPARE_BEFROE_START_ANI;
//                        return;
//                    }
            }
            break;
        }

        case Turn.MONSTER:
        {
            switch (state)
            {
            case State.VICTORY:
            {
                return;
            }

            case State.DEFEATED:
            {
                return;
            }
//                    case State.PREPARE_BEFROE_START_ANI:
//                    {
//                        // before battle start
//						// init animation and play
//
//                        state = State.ING_BEFROE_START_ANI;
//                        return;
//                    }
//                    case State.ING_BEFROE_START_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//
//                        state = State.PREPARE_BUFF_EFFECT_ANI;
//                        return;
//                    }
//                    case State.PREPARE_BUFF_EFFECT_ANI:
//                    {
//                        // calculate the damage of continuous BUFF
//                        // init animation and play
//
//                        state = State.ING_BUFF_EFFECT_ANI;
//                        return;
//                    }
//                    case State.ING_BUFF_EFFECT_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//						state = State.BUFF_EFFECT_JUDEMENT;
//                        return;
//                    }
//                    case State.BUFF_EFFECT_JUDEMENT:
//                    {
//                        // judge if some one win
//
//                        state = State.PREPARE_DICE_1_ANI;
//                        return;
//                    }
//                    case State.PREPARE_DICE_1_ANI:
//                    {
//                        // random dice 1
//						// init animation and play
//						Mturn++;
//						monsterTurn.text = Mturn.ToString() + " : MTurn";
//
//                        state = State.ING_DICE_1_ANI;
//                        return;
//                    }
//                    case State.ING_DICE_1_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//						state = State.SELECT_SKILL;
//                        return;
//                    }
//                    case State.SELECT_SKILL:
//                    {
//                        // choose which skill to use
//                        // according to turn
//
//                        state = State.ING_SELECT_SKILL_ANI;
//                        return;
//                    }
//                    case State.ING_SELECT_SKILL_ANI:
//                    {
//                        // do nothing
//                        // (later) animation finish event will call
//
//                        state = State.PREPARE_DICE_2_ANI;
//                        return;
//                    }
//                    case State.PREPARE_DICE_2_ANI:
//                    {
//                        // random dice 2
//                        // init animation and play
//
//                        state = State.ING_DICE_2_ANI;
//                        return;
//                    }
//                    case State.ING_DICE_2_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//						state = State.PREPARE_SKILL_ANI;
//                        return;
//                    }
//                    case State.PREPARE_SKILL_ANI:
//                    {
//                        // init skill animation and play
//
//                        state = State.ING_SKILL_ANI;
//                        return;
//                    }
//                    case State.ING_SKILL_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//						state = State.REMOVE_BUFF;
//                        return;
//                    }
//                    case State.REMOVE_BUFF:
//                    {
//                        // remove some buff according to skill
//
//                        state = State.ADD_BUFF;
//                        return;
//                    }
//                    case State.ADD_BUFF:
//                    {
//                        // add some buff according to skill
//
//                        state = State.PREPARE_DAMAGE_ANI;
//                        return;
//                    }
//                    case State.PREPARE_DAMAGE_ANI:
//                    {
//                        // init animation with damage and play
//
//                        state = State.ING_DAMAGE_ANI;
//                        return;
//                    }
//                    case State.ING_DAMAGE_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//                        state = State.JUDGEMENT;
//                        return;
//                    }
//                    case State.JUDGEMENT:
//                    {
//                        // judge if some one win
//
//                        state = State.BUFF_COUNT;
//                        return;
//                    }
//                    case State.BUFF_COUNT:
//                    {
//                        // all turns of buff minus 1
//
//                        state = State.PREPARE_TURN_END_ANI;
//
//						// for test
//						StartCoroutine(DelayToInvoke.DelayToInvokeDo(
//							()=>{
//								state = State.ING_TURN_END_ANI;
//							}, 1.85f));
//
//                        return;
//                    }
//                    case State.PREPARE_TURN_END_ANI:
//                    {
//                        // prepare turn ending animation and play
//
//                        //state = State.ING_TURN_END_ANI;
//                        return;
//                    }
//                    case State.ING_TURN_END_ANI:
//                    {
//                        // do nothing
//                        // animation finish event will call
//
//						// clean all stage
//						dice1_obj.SetActive(false);
//						dice2_obj.SetActive (false);
//						//scroll.selectedSkill = null;
//                        // new turn with hero
//                        turnState = Turn.HERO;
//                        state = State.PREPARE_BUFF_EFFECT_ANI;
//                        return;
//                    }
            }
            break;
        }
        }
    }