예제 #1
0
        public void NextRound(Player player)
        {
            if (IsFinish())
            {
                return;
            }

            if (!InProgress())
            {
                //can be started?
                if (reqs.Check(player, true))
                {
                    status = 1;
                    //inform player
                    Info i = new Info(name, Icon);
                    if (main)
                    {
                        i.Important(desc);
                    }
                    player.info.Add(i);
                }
                else
                {
                    return;
                }
            }

            //fullfilled?
            //Debug.Log(name+" "+ReqHelper.Check(player, reqs));

            if (reqs.Check(player))
            {
                status = 2;
                actions.Performs(ActionEvent.Quest, player);
            }
        }
예제 #2
0
파일: Spell.cs 프로젝트: TrutzX/9Nations
        public void Perform(Player player, MapElementInfo mapElementInfo, NVector pos, bool ani)
        {
            //mapElementInfo.data.ap -= cost;
            var    target = S.MapElement(pos);
            string msg    = null;
            int    ap     = 0;
            int    chance = mapElementInfo.data.spells.CalcChance(id);

            mapElementInfo.data.spells.Cast(id);
            target = (target != null) ? target : mapElementInfo;
            //can perform?
            if (chance > Random.Range(0, 100))
            {
                //calc cost
                foreach (var ah in action.actions)
                {
                    ap += ah.DataAction().cost;
                }

                mapElementInfo.data.ap += ap; //tmp for spell using
                msg = action.Performs(ActionEvent.All, player, target, pos);

                //success?
                if (String.IsNullOrEmpty(msg))
                {
                    if (ani && !String.IsNullOrEmpty(animation))
                    {
                        L.b.animations.Create(animation, pos);
                        NAudio.Play(Sound);
                        if (!mapElementInfo.IsBuilding())
                        {
                            ((UnitInfo)mapElementInfo).UnitAnimator().PlayIdleAnimation(UnitAnimatorType.Cast);
                        }
                    }

                    mapElementInfo.AddNoti(S.T("spellSuccess", Name()), Icon);

                    return;
                }
            }

            //falure

            //calc cost
            ap = 0;
            foreach (var ah in action.actions)
            {
                ap += ah.DataAction().cost;
            }

            mapElementInfo.data.ap += ap; //tmp for spell using
            var nmsg = actionFail.Performs(ActionEvent.All, player, target, pos);

            if (ani)
            {
                L.b.animations.Create("broken", pos);
                mapElementInfo.UI().ShowPanelMessageError(S.T("spellError", Name()));
            }

            msg = $"{msg} {nmsg}";

            mapElementInfo.AddNoti(S.T("spellError", Name(), msg), Icon);
        }