コード例 #1
0
ファイル: Enemy.cs プロジェクト: clifordunique/Hunter
    protected void Attack()
    {
        if (curAttackCD <= Time.time)
        {
            if (!isAttack)
            {
                if (target != null)
                {
                    int _random      = Random.Range(0, 100);
                    int _chance      = 0;
                    int _comboNumber = 0;

                    foreach (KeyValuePair <string, EnemyCombo> combo in combos)
                    {
                        if (_random < combo.Value.chance + _chance)
                        {
                            //If player too far
                            if (DistanceToPlayer().x > attackRange.x + combo.Value.attackRange || DistanceToPlayer().x <= (attackRange.x + combo.Value.attackRange) / 2f)
                            {
                                SwitchState(State.Chase);
                                return;
                            }

                            curAttackNumber = 0;
                            comboNumber     = _comboNumber;
                            curCombo        = combo.Value;
                            lastAttack      = combo.Key;
                            break;
                        }

                        _comboNumber++;
                        _chance += combo.Value.chance;
                    }

                    //Flip enemy towards the player
                    if (Mathf.Sign(target.transform.position.x - transform.position.x) != direction)
                    {
                        FlipCharacter(false);
                    }

                    isAttack = true;
                }
                else
                {
                    SwitchState(State.Patrol);
                }
            }
            else if (increaseAttackNumber)
            {
                curAttackNumber++;      //This will switch the animation to the next attack
                increaseAttackNumber = false;

                //Flip enemy towards the player
                if (Mathf.Sign(target.transform.position.x - transform.position.x) != direction)
                {
                    FlipCharacter(false);
                }
            }
        }
    }
コード例 #2
0
    public void setCardLook(EnemyCombo enemies)
    {
        int totalNum = 0;

        for (int i = 0; i < enemies.enemyId.Count; i++)
        {
            totalNum += enemies.enemyNum [i];
        }
    }
コード例 #3
0
 void Begin()
 {
     enemySeeker       = GetComponent <EnemySeeker>();
     enemyCombo        = GetComponent <EnemyCombo>();
     enemyRetreat      = GetComponent <EnemyRetreat>();
     enemyRecoverer    = GetComponent <EnemyRecoverer>();
     enemyDeath        = GetComponent <EnemyDeath>();
     enemyGravityCheck = GetComponent <EnemyGravityCheck>();
 }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: nmbswls/asdas
    public void addMonsterView(EnemyCombo enemyInfo, Vector2 originPos)
    {
        MonsterCardComponent item = (MonsterCardComponent)UIPackage.CreateObject("UIMain", "MonsterCard").asCom;

        monsterContianer.AddChild(item);
        item.SetXY(-100, -100);
        //item.setName (enemyInfo.enemyId+"");
        item.setInfo(enemyInfo);
        item.visible = false;
        showAddMonsterEffect(originPos, monsterContianer.LocalToGlobal(item.position), item);
        reArrangeEnemies();
    }
コード例 #5
0
    public EnemyCombo getEnemyWithValue(int v)
    {
        EnemyCombo ec = new EnemyCombo();

        if (v <= 8)
        {
            int    a       = enemyPerLv [1].Count;
            int    randInt = Random.Range(0, a - 1);
            string eId     = enemyPerLv [1] [randInt];
            ec.enemyId.Add(eId);
            ec.enemyNum.Add(v);
        }
        return(ec);
    }
コード例 #6
0
    public EnemyCombo getSpecifiedEnemy(string ename)
    {
        EnemyCombo ec = new EnemyCombo();

        //EnemyData ed = enemyStaticInfo [ename];
        ec.enemyId = new List <string>()
        {
            ename
        };
        ec.enemyNum = new List <int>()
        {
            1
        };
        return(ec);
    }
コード例 #7
0
 public void setInfo(EnemyCombo info)
 {
     this.info = info;
     for (int i = 0; i < 3; i++)
     {
         if (i >= info.enemyId.Count)
         {
             break;
         }
         string eid   = info.enemyId [i];
         int    num   = info.enemyNum [i];
         string ename = GameStaticData.getInstance().getEnemyInfo(eid).enemyName;
         numberTF [i].text    = "x" + num;
         nameTF [i].text      = ename;
         numberTF [i].visible = true;
         nameTF [i].visible   = true;
     }
     //this.GetController ("c0").;
 }
コード例 #8
0
    void loadEnemyInfo()
    {
        TextAsset ta = Resources.Load("json/enemy/all") as TextAsset;

        enemyStaticInfo = JsonConvert.DeserializeObject <Dictionary <string, EnemyData> > (ta.text);

        foreach (EnemyData ed in enemyStaticInfo.Values)
        {
            if (!enemyPerLv.ContainsKey(ed.difficulty))
            {
                enemyPerLv [ed.difficulty] = new List <string> ();
            }
            enemyPerLv [ed.difficulty].Add(ed.enemyId);
        }

        {
            EnemyCombo combo = new EnemyCombo();
            enemyCombos ["0"] = combo;
        }
    }
コード例 #9
0
    void changeView(int stageIndex)
    {
        EncounterStage stage = null;

        converters.Clear();
        if (!encounter.stages.TryGetValue(stageIndex, out stage))
        {
            return;
        }
        if (stage.extra == "monster")
        {
            EnemyCombo ec = GameStaticData.getInstance().getEnemyWithValue(5);
            GameManager.getInstance().chaseByEnemy(ec);
        }
        else if (stage.extra == "toturial_monster")
        {
            EnemyCombo ec = GameStaticData.getInstance().getSpecifiedEnemy("toturial");
            GameManager.getInstance().chaseByEnemy(ec);
        }

        if (stage.stageType == eStageType.FINISH)
        {
            getRes(stage.res);
            return;
        }
        else if (stage.stageType == eStageType.BATTLE)
        {
            EncounterBattleInfo battleInfo = stage.battleInfo;

            PlayerData.getInstance().initBattle(encounter.eId, stageIndex, battleInfo);
            GameManager.getInstance().enterBattle();
            this.Hide();
            return;
        }
        else if (stage.stageType == eStageType.CHECK)
        {
            Debug.Log("check");

            int nextStage = -1;
            for (int i = 0; i < stage.converts.Count - 1; i++)
            {
                EncounterConvert convert    = stage.converts [i];
                bool             canConvert = checkConditions(convert.checks);
                if (canConvert)
                {
                    nextStage = convert.nextStageIdx;
                    break;
                }
            }
            if (nextStage == -1)
            {
                nextStage = stage.converts [stage.converts.Count - 1].nextStageIdx;
            }
            if (nextStage != -1)
            {
                stageIndex = nextStage;
                changeView(stageIndex);
            }
            else
            {
                Debug.Log("error");
                panelHide();
            }
        }
        else if (stage.stageType == eStageType.RANDOM)
        {
            int randomInt = Random.Range(0, 99);
            int nextStage = -1;
            for (int i = 0; i < stage.converts.Count - 1; i++)
            {
                EncounterConvert convert    = stage.converts [i];
                bool             canConvert = checkConditions(convert.checks, randomInt);
                if (canConvert)
                {
                    nextStage = convert.nextStageIdx;
                    break;
                }
            }
            if (nextStage == -1)
            {
                nextStage = stage.converts [stage.converts.Count - 1].nextStageIdx;
            }
            if (nextStage != -1)
            {
                stageIndex = nextStage;
                changeView(stageIndex);
            }
            else
            {
                Debug.Log("error");
                panelHide();
            }
        }
        else
        {
            _text.text = stage.desp;
            int idx = 0;


            _branches.ClearSelection();
            _branches.RemoveChildrenToPool();


//			for(int i=0;i<items.Count;i++)
//			{
//				NewItem item = (NewItem)_new_item_list.AddItemFromPool();
//				item.init (items[i]);
//				item.onClick.Add (delegate() {
//					if(_new_item_list.selectedIndex!=-1){
//						_confirm.visible = true;
//					}
//					if (PlayerData.getInstance ().guideStage == 10) {
//						GuideManager.getInstance ().showGuideConfirmChooseItem ();
//						PlayerData.getInstance ().guideStage = 11;
//					}
//				});
//				item.GetChild ("detail").onTouchBegin.Add (delegate() {
//					//Debug.Log("Show Detail");
//				});
//			}

            int numOfBranch = 0;


            for (int i = 0; i < stage.converts.Count; i++)
            {
                EncounterConvert convert = stage.converts [i];
                bool             canShow = checkConditions(convert.checks);
                //EncounterConvert convert = stage.converts [i];
                if (canShow)
                {
                    SelectionBranch item = (SelectionBranch)_branches.AddItemFromPool().asButton;
                    item.init(numOfBranch++, convert.choiceDesp);
                    item.visible = true;
                    converters.Add(convert);
                }
            }
            _branches.ResizeToFit(numOfBranch);

//			for (int i = 0; i < stage.converts.Count; i++) {
//				EncounterConvert convert = stage.converts [i];
//				bool canShow = checkConditions (convert.checks);
//				//EncounterConvert convert = stage.converts [i];
//				if (canShow) {
//
//					SelectionBranch item = (SelectionBranch)_branches.GetChildAt (i).asButton;
//					item.idx = numOfBranch ++ ;
//
//					_branches.GetChildAt(idx).asButton.title = convert.choiceDesp;
//					_branches.GetChildAt(idx).visible = true;
//					converters.Add (convert);
//					idx++;
//
//
//				}
//			}
//			for (int i = idx; i < MAX_BRANCH_NUM; i++) {
//				_branches.GetChildAt(i).asButton.title ="";
//				_branches.GetChildAt(i).visible = false;
//			}

            _loader.url = "Explore/default_bg";
        }

        if (PlayerData.getInstance().guideStage == 2)
        {
            PlayerData.getInstance().guideStage = 3;
            GuideManager.getInstance().showGuideChooseBranch();
        }
        else if (PlayerData.getInstance().guideStage == 3)
        {
            PlayerData.getInstance().guideStage = 4;
            GuideManager.getInstance().showGuideChooseBranch();
        }
        else if (PlayerData.getInstance().guideStage == 4)
        {
            GuideManager.getInstance().hideGuide();
        }
    }
コード例 #10
0
ファイル: PlayerData.cs プロジェクト: nmbswls/asdas
 public void addMonster(EnemyCombo enemyAbstract)
 {
     chasingEnemies.Add(enemyAbstract);
 }
コード例 #11
0
ファイル: GameManager.cs プロジェクト: nmbswls/asdas
 public void chaseByEnemy(EnemyCombo enemyInfo, Vector2 originPos)
 {
     PlayerData.getInstance().addMonster(enemyInfo);
     addMonsterView(enemyInfo, originPos);
     //StartCoroutine (lateCheckIfBattle());
 }
コード例 #12
0
ファイル: GameManager.cs プロジェクト: nmbswls/asdas
    public void chaseByEnemy(EnemyCombo enemy)
    {
        Vector2 center = new Vector2(GRoot.inst.width / 2, GRoot.inst.height / 2);

        chaseByEnemy(enemy, center);
    }