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

            cdHandler = new CooldownHandler(Util.Rand(turnCooldown));
            cdHandler.StartCooldown();
        }
Ejemplo 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));
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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);
            }
        }
Ejemplo 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();
        }
Ejemplo 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>();
        }
Ejemplo 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();
            }
        }
Ejemplo 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;
            }
        }
Ejemplo 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());
        }
Ejemplo 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));
            }
        }
Ejemplo n.º 12
0
 public AIStrategy Create(IAIEntity aiEntity)
 {
     return(Create(aiEntity, null));
 }
Ejemplo n.º 13
0
 public ForwardStrategy(IAIEntity controlled, int shootCd = 0) : base(controlled, shootCd)
 {
 }
Ejemplo n.º 14
0
 public override void OnAwake()
 {
     this.monster        = base.GetComponent <BaseMonoMonster>();
     this._aiEntity      = this.monster;
     this._levelAIPlugin = Singleton <LevelManager> .Instance.levelActor.GetPlugin <LevelAIPlugin>();
 }
Ejemplo n.º 15
0
 public CrazyRotatingStrategy(IAIEntity controlled, int shootCd = 0) : base(controlled, shootCd)
 {
     rotationDir = Util.Rand(-1, 2);
 }
Ejemplo 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();
 }
Ejemplo n.º 17
0
 public override void OnAwake()
 {
     this._aiEntity = (IAIEntity)base.GetComponent <BaseMonoAnimatorEntity>();
 }
Ejemplo n.º 18
0
 public StaticStrategy(IAIEntity controlled, int shootCooldown = 0) : base(controlled, shootCooldown)
 {
     targetDir = Util.RandomUnitVector();
 }
Ejemplo n.º 19
0
        public override void OnAwake()
        {
            BaseMonoAnimatorEntity component = base.GetComponent <BaseMonoAnimatorEntity>();

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