Esempio n. 1
0
        public ErraticStrategy(IAIEntity controlled, int shootCooldown) : base(controlled, shootCooldown)
        {
            turnCooldown = 5000;

            cdHandler = new CooldownHandler(Util.Rand(turnCooldown));
            cdHandler.StartCooldown();
        }
Esempio n. 2
0
        public AIStrategy CreateByName(string strategy, IAIEntity aiEntity, IHandlesEntities entHandler)
        {
            switch (strategy.ToLower())
            {
            case "crazyrotating":
                return(new CrazyRotatingStrategy(aiEntity, shootCooldown));

            case "chase":
                return(new ChaseStrategy(aiEntity, entHandler, shootCooldown));

            case "erratic":
                return(new ErraticStrategy(aiEntity, shootCooldown));

            case "static":
                return(new StaticStrategy(aiEntity, shootCooldown));

            case "forward":
                return(new ForwardStrategy(aiEntity, shootCooldown));

            case "spreadforward":
                return(new SpreadForwardStrategy(aiEntity, shootCooldown));

            default:
                return(new StaticStrategy(aiEntity, shootCooldown));
            }
        }
Esempio n. 3
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            if (component is BaseMonoAvatar)
            {
                this._aiEntity          = (BaseMonoAvatar)component;
                this.moveSpeedKey.Value = "AvatarSpeed(FIXED)";
                this._speed             = 0f;
            }
            else if (component is BaseMonoMonster)
            {
                this._aiEntity = (BaseMonoMonster)component;
                this._speed    = (component as BaseMonoMonster).GetOriginMoveSpeed(this.moveSpeedKey.Value);
            }
            this._aiController = this._aiEntity.GetActiveAIController();
            this._monster      = this._aiEntity as BaseMonoMonster;
            if (this.failMoveTime <= 0f)
            {
                this._usefailMoveTime = false;
            }
            else
            {
                this._usefailMoveTime = true;
                this._failMoveTimer   = this.failMoveTime;
            }
        }
Esempio n. 4
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            if (component is BaseMonoAvatar)
            {
                this._aiEntity = (BaseMonoAvatar)component;
            }
            else if (component is BaseMonoMonster)
            {
                this._aiEntity = (BaseMonoMonster)component;
            }
        }
Esempio n. 5
0
        public AIStrategy(IAIEntity controlled, int shootCd = 0)
        {
            this.controlled = controlled;
            targetDir       = Util.RandomUnitVector();

            commandHistory = new CommandHistory(200);
            CreateCommands();

            if (shootCd > 0)
            {
                shootCooldown = new CooldownHandler(shootCd * 1000);
            }
        }
Esempio n. 6
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            if (component is BaseMonoAvatar)
            {
                this._aiEntity = (BaseMonoAvatar)component;
            }
            else if (component is BaseMonoMonster)
            {
                this._aiEntity = (BaseMonoMonster)component;
            }
            this._aiController = this._aiEntity.GetActiveAIController();
        }
Esempio n. 7
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            if (component is BaseMonoAvatar)
            {
                this._aiEntity = (BaseMonoAvatar)component;
            }
            else if (component is BaseMonoMonster)
            {
                this._aiEntity = (BaseMonoMonster)component;
            }
            this._aiController  = this._aiEntity.GetActiveAIController();
            this._abilityEntity = component;
            this._levelAIPlugin = Singleton <LevelManager> .Instance.levelActor.GetPlugin <LevelAIPlugin>();
        }
Esempio n. 8
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            if (component is BaseMonoAvatar)
            {
                this._aiEntity = (BaseMonoAvatar)component;
            }
            else if (component is BaseMonoMonster)
            {
                this._aiEntity = (BaseMonoMonster)component;
            }
            foreach (CDInfo info in this.cdList)
            {
                info.InitOnAwake();
            }
        }
Esempio n. 9
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            if (component is BaseMonoAvatar)
            {
                this._aiEntity = (BaseMonoAvatar)component;
            }
            else if (component is BaseMonoMonster)
            {
                this._aiEntity = (BaseMonoMonster)component;
            }
            if (this.isRandom)
            {
                this.CD.Value = UnityEngine.Random.Range(this.minRandTime, this.maxRandTime);
            }
            else
            {
                this.CD.Value = this.defaultTime;
            }
        }
Esempio n. 10
0
        public override TaskStatus OnUpdate()
        {
            BaseMonoEntity component = base.GetComponent <BaseMonoMonster>();

            this._aiEntity = (BaseMonoMonster)component;
            if (this._aiEntity.GetProperty("AI_IgnoreMaxAttackNumChance") > 0f)
            {
                return(TaskStatus.Success);
            }
            if (!Singleton <CameraManager> .Instance.GetMainCamera().IsEntityVisibleInCustomOffset(component, -5f, 5f, 0f))
            {
                if (Singleton <CameraManager> .Instance.GetMainCamera().GetVisibleMonstersCountWithOffset(-5f, 5f, 0f) < this.avatarBeAttackMaxNum.Value)
                {
                    return(this.CheckCanAttackWithMaxNum());
                }
                if (UnityEngine.Random.value < this.resetAttackCDPos.Value)
                {
                    this.AttackCD.Value = this.resetAttackCDTime.Value;
                    return(TaskStatus.Failure);
                }
            }
            return(this.CheckCanAttackWithMaxNum());
        }
Esempio n. 11
0
        public AIStrategy Create(IAIEntity aiEntity, IHandlesEntities entHandler)
        {
            //generate random number up to the difficulty level
            int n = Util.Rand(difficultyLevel);

            //return the hardest strategy that the number can get
            if (n < 5)
            {
                return(new CrazyRotatingStrategy(aiEntity, shootCooldown));
            }
            else if (n < 10)
            {
                return(new StaticStrategy(aiEntity, shootCooldown));
            }
            else if (n < 20)
            {
                return(new ErraticStrategy(aiEntity, shootCooldown));
            }
            else
            {
                return(new ChaseStrategy(aiEntity, entHandler, shootCooldown));
            }
        }
Esempio n. 12
0
 public AIStrategy Create(IAIEntity aiEntity)
 {
     return(Create(aiEntity, null));
 }
Esempio n. 13
0
 public ForwardStrategy(IAIEntity controlled, int shootCd = 0) : base(controlled, shootCd)
 {
 }
Esempio n. 14
0
 public override void OnAwake()
 {
     this.monster        = base.GetComponent <BaseMonoMonster>();
     this._aiEntity      = this.monster;
     this._levelAIPlugin = Singleton <LevelManager> .Instance.levelActor.GetPlugin <LevelAIPlugin>();
 }
Esempio n. 15
0
 public CrazyRotatingStrategy(IAIEntity controlled, int shootCd = 0) : base(controlled, shootCd)
 {
     rotationDir = Util.Rand(-1, 2);
 }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AIContext"/> class.
 /// </summary>
 /// <param name="entity">The entity for whom this context belongs to.</param>
 public AIContext(IAIEntity entity)
 {
     this.entity           = entity;
     this.sampledPositions = new List <Vector3>(64);
     this.memory           = new AIMemory();
 }
Esempio n. 17
0
 public override void OnAwake()
 {
     this._aiEntity = (IAIEntity)base.GetComponent <BaseMonoAnimatorEntity>();
 }
Esempio n. 18
0
 public StaticStrategy(IAIEntity controlled, int shootCooldown = 0) : base(controlled, shootCooldown)
 {
     targetDir = Util.RandomUnitVector();
 }
Esempio n. 19
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

            this._aiEntity = (BaseMonoMonster)component;
        }
Esempio n. 20
0
 public SpreadForwardStrategy(IAIEntity controlled, int shootCd = 0) : base(controlled, shootCd)
 {
     rotationDir = Util.Rand(-1, 3);
 }
Esempio n. 21
0
 public ChaseStrategy(IAIEntity controlled, IHandlesEntities entHandler, int shootCooldown = 0) : base(controlled, shootCooldown)
 {
     this.entHandler = entHandler;
     agroRange       = SwinGame.ScreenWidth() / 1.5f;
 }