Example #1
0
 public BaseBehaviour(EnemyObj enemy, BaseAICtrler ctrler)
 {
     _Actor        = enemy;
     _AICtrler     = ctrler;
     _ActionCtrler = _Actor.ActionCtrl;
     _Inited       = false;
 }
Example #2
0
    GameObject GetEnemy(GameObject enemy)
    {
        GameObject retrievedEnemy = null;

        if (EnemyPool.ContainsKey(enemy))
        {
            foreach (var e in EnemyPool[enemy])
            {
                if (e.go == null)
                {
                    continue;
                }
                if (e.go.activeSelf == false)
                {
                    return(e.go);
                }
            }
        }
        else
        {
            EnemyPool.Add(enemy, new List <EnemyObj>());
        }

        if (retrievedEnemy == null)
        {
            retrievedEnemy = Instantiate(enemy, transform);
            EnemyObj enemyObj = new EnemyObj();
            enemyObj.go          = retrievedEnemy;
            enemyObj.enemyScript = retrievedEnemy.GetComponent <Enemy>();
            EnemyPool[enemy].Add(enemyObj);
        }
        return(retrievedEnemy);
    }
Example #3
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         m_obj = null;
         base.Dispose();
     }
 }
Example #4
0
 public override void Execute()
 {
     if (ParentLogicSet != null && ParentLogicSet.IsActive)
     {
         m_obj        = (ParentLogicSet.ParentGameObj as EnemyObj);
         SequenceType = Types.Sequence.Serial;
         base.Execute();
     }
 }
Example #5
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title            = "Chọn ảnh map";
            ofd.Filter           = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
            ofd.InitialDirectory = @"C:\Users\dell\Desktop\";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                MyLogger.getInstance().logDebug("Open map ------------------------------------------");
                String fileName   = ofd.FileName.Split('.')[0];
                Bitmap background = context.open(fileName);
                background.MakeTransparent(Color.FromArgb(255, 0, 255));
                this.width_map  = background.Width;
                this.height_map = background.Height;
                this.bmp_map    = new Bitmap(background);
                int count_horizontal = this.width_map / 16;
                int count_vertical   = this.height_map / 16;

                this.bmp_map = new Bitmap(background);

                Bitmap _bmp = CreateMapSquare(background);

                using (Graphics g = Graphics.FromImage(_bmp))
                {
                    for (int row = 0; row < count_vertical; row++)
                    {
                        for (int col = 0; col < count_horizontal; col++)
                        {
                            g.DrawLine(Pens.Red, new Point(col * 16, 0), new Point(col * 16, this.height_map));
                        }

                        g.DrawLine(Pens.Red, new Point(0, row * 16), new Point(this.width_map, row * 16));
                    }
                }

                picMap.SizeMode = PictureBoxSizeMode.AutoSize;
                picMap.Image    = _bmp;
                background      = _bmp;

                RecObject recobj = new RecObject();
                recobj.parse(fileName + "recs.txt");
                this.recs.AddRange(recobj.Recs);

                EnemyObj enemyObj = new EnemyObj();
                enemyObj.parse(fileName + "enemy.txt");
                this.enemies.AddRange(enemyObj.Enemies);

                foreach (ObjGame obj in enemyObj.Enemies)
                {
                    ObjDTO objDTO = new ObjDTO(obj, folderDefault + "enemy/" + obj.Name + ".png");
                    pushObjGame(obj.X, obj.Y, objDTO);
                }
            }
        }
Example #6
0
 public Enemy(String fileName)
 {
     objDefault = new EnemyObj();
     objDefault.parse(fileName);
     this.X      = objDefault.X;
     this.Y      = objDefault.Y;
     this.Width  = objDefault.Width;
     this.Height = objDefault.Height;
     this.Type   = objDefault.Type;
     this.Name   = objDefault.Name;
 }
Example #7
0
    public NPCActionControler(EnemyObj enemyObj) : base(enemyObj, enemyObj.animator)
    {
        Vector2 guardSize = enemyObj.guardSize;
        Vector2 shift     = enemyObj.guardShiftValue;
        Vector2 position  = enemyObj.guartPoint;

        leftGuardPoint     = position + shift;
        leftGuardPoint.z   = npcActor.transform.position.z;
        rightGuardPoint    = leftGuardPoint;
        leftGuardPoint.x  -= guardSize.x / 2;
        rightGuardPoint.x += guardSize.x / 2;
    }
Example #8
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
    {
        EnemyObj           enemyObj           = BaseActorObj.GetActorByAnimatorTransform(animator.transform) as EnemyObj;
        NPCActionControler npcActionControler = enemyObj.actionControler;

        if (maxRandomTime > 0 && minRandomTime > 0)
        {
            float randomTime = maxRandomTime == minRandomTime ? maxRandomTime : (maxRandomTime - minRandomTime) * Random.value + minRandomTime;
            npcActionControler.timeTamp = Time.time + randomTime;
        }
        base.OnStateEnter(animator, animatorStateInfo, layerIndex);
        animator.SetFloat("randomValue", Random.value);
    }
Example #9
0
    private void TestHp()
    {
        ScaleHp.GetComponent <Transform>().localScale = new Vector3((currentHp / maxHp), ScaleHp.GetComponent <Transform>().localScale.y, ScaleHp.GetComponent <Transform>().localScale.z);
        TextHp.GetComponent <Text>().text             = currentHp + "/" + maxHp;

        if (currentHp <= 0)
        {
            try
            {
                foreach (GameObject EnemyObj in GameObject.FindGameObjectsWithTag("Enemy"))
                {
                    EnemyObj.GetComponent <Inimigo1>().hp = 0;
                }
                foreach (GameObject EnemyObj in GameObject.FindGameObjectsWithTag("Tiro"))
                {
                    EnemyObj.SetActive(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            xspeed = 0;
            if (!deathCycleDone)
            {
                Destroy(GetComponent <Collider2D>());
                Destroy(gameObject, 1f);
                GetComponent <Animator>().SetBool("Explodir", true);
                deathCycleDone = true;
                for (int i = 0; i < 30; i++)
                {
                    GameObject newCoin = Instantiate(Coin);
                    newCoin.GetComponent <Transform>().position = new Vector3(tr.position.x + UnityEngine.Random.Range(-GetComponent <RectTransform>().rect.width * 2, GetComponent <RectTransform>().rect.width * 2), tr.position.y + UnityEngine.Random.Range(-GetComponent <RectTransform>().rect.height * 2, GetComponent <RectTransform>().rect.height * 2), tr.position.z);
                }
            }
        }
    }
Example #10
0
 public RunToBehaviour(EnemyObj enemy, BaseAICtrler ctrler, float distance, string paramName = "QuickRun", Action endFunc = null) : base(enemy, ctrler)
 {
     _EndFunc        = endFunc;
     _TargetDistance = distance;
     _ParamName      = paramName;
 }
Example #11
0
 public ChasingBehaviour(EnemyObj Enemy, BaseAICtrler ctrler, float distance, float limitTime = -1) : base(Enemy, ctrler)
 {
     ChasingAction = Enemy.ActionCtrl.CurAction;
     _Distacnce    = distance;
     _LimitTime    = limitTime;
 }
Example #12
0
        public static EnemyObj BuildEnemy(int enemyType, PlayerObj player, PhysicsManager physicsManager,
                                          ProceduralLevelScreen levelToAttachTo, GameTypes.EnemyDifficulty difficulty, bool doNotInitialize = false)
        {
            EnemyObj enemyObj = null;

            switch (enemyType)
            {
            case 1:
                enemyObj = new EnemyObj_BallAndChain(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 2:
                enemyObj = new EnemyObj_Blob(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 3:
                enemyObj = new EnemyObj_BouncySpike(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 4:
                enemyObj = new EnemyObj_Eagle(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 5:
                enemyObj = new EnemyObj_EarthWizard(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 6:
                enemyObj = new EnemyObj_Eyeball(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 7:
                enemyObj = new EnemyObj_Fairy(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 8:
                enemyObj = new EnemyObj_Fireball(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 9:
                enemyObj = new EnemyObj_FireWizard(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 10:
                enemyObj = new EnemyObj_Horse(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 11:
                enemyObj = new EnemyObj_IceWizard(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 12:
                enemyObj = new EnemyObj_Knight(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 13:
                enemyObj = new EnemyObj_Ninja(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 14:
                enemyObj = new EnemyObj_ShieldKnight(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 15:
                enemyObj = new EnemyObj_Skeleton(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 16:
                enemyObj = new EnemyObj_SwordKnight(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 17:
                enemyObj = new EnemyObj_Turret(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 18:
                enemyObj = new EnemyObj_Wall(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 19:
                enemyObj = new EnemyObj_Wolf(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 20:
                enemyObj = new EnemyObj_Zombie(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 21:
                enemyObj = new EnemyObj_SpikeTrap(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 22:
                enemyObj = new EnemyObj_Plant(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 23:
                enemyObj = new EnemyObj_Energon(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 24:
                enemyObj = new EnemyObj_Spark(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 25:
                enemyObj = new EnemyObj_SkeletonArcher(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 26:
                enemyObj = new EnemyObj_Chicken(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 27:
                enemyObj = new EnemyObj_Platform(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 28:
                enemyObj = new EnemyObj_HomingTurret(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 29:
                enemyObj = new EnemyObj_LastBoss(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 30:
                enemyObj = new EnemyObj_Dummy(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 31:
                enemyObj = new EnemyObj_Starburst(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 32:
                enemyObj = new EnemyObj_Portrait(player, physicsManager, levelToAttachTo, difficulty);
                break;

            case 33:
                enemyObj = new EnemyObj_Mimic(player, physicsManager, levelToAttachTo, difficulty);
                break;
            }
            if (player == null && !doNotInitialize)
            {
                enemyObj.Initialize();
            }
            return(enemyObj);
        }
Example #13
0
 // Use this for initialization
 public NormalBehaviour(EnemyObj enemy, BaseAICtrler ctrler, float continueTime) : base(enemy, ctrler)
 {
     _ContinueTime = continueTime;
 }
Example #14
0
 public BossAICtrler(EnemyObj enemyObj, ActionCtrler actionCtrler) : base(enemyObj, actionCtrler)
 {
     _BirthPlace = enemyObj.transform.position;
 }
Example #15
0
 public GuardBehaviour(EnemyObj enemyObj, BaseAICtrler aiCtrler, float time) : base(enemyObj, aiCtrler)
 {
     _Time = time;
 }
Example #16
0
 public NormalEnemyOverWaltch(EnemyObj obj, SkillInfo skillInfo) : base(obj, skillInfo)
 {
 }
Example #17
0
        private void FixMiniboss(EnemyObj enemy)
        {
            var type = enemy.Type;

            switch (type)
            {
            case 2:
                m_blobBoss = (enemy as EnemyObj_Blob);
                enemy.ChangeSprite("EnemyBlobBossIdle_Character");
                enemy.GetChildAt(0).TextureColor = Color.White;
                enemy.GetChildAt(2).TextureColor = Color.LightSkyBlue;
                enemy.GetChildAt(2).Opacity      = 0.8f;
                (enemy.GetChildAt(1) as SpriteObj).OutlineColour = Color.Black;
                enemy.GetChildAt(1).TextureColor = Color.Black;
                break;

            case 3:
            case 4:
                break;

            case 5:
                if (enemy.Flip == SpriteEffects.None)
                {
                    enemy.Name = "Amon";
                }
                else
                {
                    enemy.Name = "Barbatos";
                }
                break;

            case 6:
                enemy.ChangeSprite("EnemyEyeballBossEye_Character");
                (enemy as EnemyObj_Eyeball).ChangeToBossPupil();
                break;

            case 7:
                enemy.ChangeSprite("EnemyFairyGhostBossIdle_Character");
                break;

            case 8:
                enemy.ChangeSprite("EnemyGhostBossIdle_Character");
                break;

            default:
                if (type != 15)
                {
                    if (type == 22)
                    {
                        if (enemy.Flip == SpriteEffects.None)
                        {
                            enemy.Name = "Stolas";
                        }
                        else
                        {
                            enemy.Name = "Focalor";
                        }
                    }
                }
                else if (enemy.Flip == SpriteEffects.None)
                {
                    enemy.Name = "Berith";
                }
                else
                {
                    enemy.Name = "Halphas";
                }
                break;
            }
            enemy.PlayAnimation();
        }
Example #18
0
 // Use this for initialization
 public NpcBaseAction(BaseActorObj baseActorObj, SkillInfo skillInfo) : base(baseActorObj, skillInfo)
 {
     npcActor = baseActorObj as EnemyObj;
 }
Example #19
0
    public void AddObj()
    {
        if (boardLenth == 0)
        {
            titleContents = "必须先创建一个地形";
            isShowWindow  = true;
            return;
        }
        if (posX.text.Length > 0)
        {
            float posx = float.Parse(posX.text);
            if (posx < 0 || posx > boardLenth)
            {
                titleContents = "PosX不符合规范(大于0且小于地形的长度)";
                isShowWindow  = true;
                return;
            }
            foreach (GameObject t in enemyList)
            {
                EnemyObj enemy = t.GetComponent <EnemyObj>();
                if (Math.Abs(posx - enemy.e.posX) < boardLenth / 30.0f)
                {
                    titleContents = "每个对象至少相隔地形长度的1/30";
                    isShowWindow  = true;
                    return;
                }
                Debug.Log("实际相隔长度" + (posx - enemy.e.posX));
                Debug.Log("至少相隔长度" + (boardLenth / 30.0));
            }
        }
        if (nameInput.text.Length > 0)
        {
            foreach (GameObject t in enemyList)
            {
                EnemyObj enemy = t.GetComponent <EnemyObj>();

                if (nameInput.text.Equals(enemy.name))
                {
                    nameInput.text = nameInput.text + "1";
                    titleContents  = "对象名字不能相同";
                    isShowWindow   = true;
                    return;
                }
            }
        }
        if (posY.text.Length > 0)
        {
            float posy = float.Parse(posY.text);
            if (posy > 17 || posy < -31)
            {
                titleContents = "PosY不符合规范(大于-31且小于17)";
                isShowWindow  = true;
                return;
            }
        }



        if (type.text.Length > 0 && posX.text.Length > 0 && posY.text.Length > 0 && C.text.Length > 0 && Size.text.Length > 0 && shakeTime.text.Length > 0 && speedipa.text.Length > 0 && beHitAni.text.Length > 0 && audioSrc.text.Length > 0)
        {
            Enemy t = new Enemy
            {
                id        = int.Parse(id.text),
                type      = int.Parse(type.text),
                name      = nameInput.text,
                posX      = float.Parse(posX.text),
                posY      = float.Parse(posY.text),
                C         = Double.Parse(C.text),
                Size      = float.Parse(Size.text),
                shakeTime = float.Parse(shakeTime.text),
                speedipa  = float.Parse(speedipa.text),
                beHitAni  = beHitAni.text,
                audioSrc  = audioSrc.text,
                isbeHit   = toggle.isOn,
                idleAni   = idleAni.text
            };
            //530是终点
            float      len  = (t.posX / boardLenth) * 530;
            GameObject game = GameObject.Instantiate(beInstance, canvas.gameObject.transform);
            game.name = t.name;
            game.GetComponent <RectTransform>().anchoredPosition = new Vector2(-393 + len, -25 + t.posY);
            game.GetComponentInChildren <Text>().text            = t.name;
            game.GetComponent <EnemyObj>().e = t;
            Button btn = game.GetComponent <Button>();
            enemyList.Add(game);
            btn.onClick.AddListener(() =>
            {
                if (btn != null)
                {
                    deleteGameObj = game;
                    //    enemyList.Remove(game);
                    Debug.Log(deleteGameObj.name);
                    titleContents  = "选是删除对象,选否取消操作";
                    isDeleteWindow = true;
                }
            });
            Debug.Log(t.posX + "y:" + t.posY);
            // hakeTime.text.Length > 0 && speedipa.text.Length > 0 && beHitAni.text.Length > 0 && audioSrc.text.Length
            // GameObject.Instantiate(,,);
        }
        else
        {
            Debug.Log("窗口打开");
            isShowWindow  = true;
            titleContents = "添加物体,你需要补充并填写数据完整";
        }
    }
Example #20
0
 public CruiseBehaviour(EnemyObj enemy, BaseAICtrler ctrler, Vector2 target) : base(enemy, ctrler)
 {
     _Target = target;
 }
Example #21
0
 // Use this for initialization
 public AttackBehaviour(EnemyObj enemy, BaseAICtrler ctrler, string setParam) : base(enemy, ctrler)
 {
     TriggerName = setParam;
 }
Example #22
0
 public BaseAICtrler(EnemyObj enemyObj, ActionCtrler actionCtrler)
 {
     _AIList       = new LinkedList <BaseBehaviour>();
     _ActorObj     = enemyObj;
     _ActionCtrler = actionCtrler;
 }
Example #23
0
 public NormAICtrler(EnemyObj enemyObj, ActionCtrler actionCtrler) : base(enemyObj, actionCtrler)
 {
 }