Ejemplo n.º 1
0
        public void Configure(EnemyStrategy newStrategy, Color color)
        {
            body.GetComponent <SpriteRenderer>().color  = color;
            sight.GetComponent <SpriteRenderer>().color = color;
            pickableMemory = new EnemyPickableMemory();
            enemyMemory    = new EnemyEnemyMemory();

            switch (newStrategy)
            {
            case EnemyStrategy.Careful:
                typeSign.GetComponent <SpriteRenderer>().sprite = carefulSprite;
                strategy = new CarefulStrategy(mover, handController, health, enemyMemory,
                                               pickableMemory);
                break;

            case EnemyStrategy.Cowboy:
                typeSign.GetComponent <SpriteRenderer>().sprite = cowboySprite;
                strategy = new CowboyStrategy(mover, handController, enemyMemory, pickableMemory);
                break;

            case EnemyStrategy.Camper:
                typeSign.GetComponent <SpriteRenderer>().sprite = camperSprite;
                strategy = new CamperStrategy(mover, handController, health, enemyMemory,
                                              pickableMemory);
                break;

            default:
                typeSign.GetComponent <SpriteRenderer>().sprite = normalSprite;
                strategy = new NormalStrategy(mover, handController, enemyMemory, pickableMemory);
                health.Heal(200);
                break;
            }
        }
Ejemplo n.º 2
0
 public CowboyStrategy(
     Mover mover,
     HandController handController,
     EnemyEnemyMemory enemyMemory,
     EnemyPickableMemory pickableMemory)
     : base(
         mover,
         handController,
         enemyMemory,
         pickableMemory)
 {
 }
 public CarefulStrategy(
     Mover mover,
     HandController handController,
     Health health,
     EnemyEnemyMemory enemyMemory,
     EnemyPickableMemory pickableMemory)
     : base(
         mover,
         handController,
         enemyMemory,
         pickableMemory)
 {
     this.health = health;
 }
Ejemplo n.º 4
0
        private void InitializeComponent()
        {
            health    = GetComponent <Health>();
            mover     = GetComponent <RootMover>();
            destroyer = GetComponent <RootDestroyer>();

            var rootTransform = transform.root;

            enemySightSensor    = rootTransform.GetComponentInChildren <EnemySightSensor>();
            pickableSightSensor = rootTransform.GetComponentInChildren <PickableSightSensor>();
            hitSensor           = rootTransform.GetComponentInChildren <HitSensor>();
            handController      = hand.GetComponent <HandController>();
            pickableMemory      = new EnemyPickableMemory();
            enemyMemory         = new EnemyEnemyMemory();
            strategy            = new NormalStrategy(mover, handController, enemyMemory, pickableMemory);
        }
        protected Strategy(
            Mover mover,
            HandController handController,
            EnemyEnemyMemory enemyMemory,
            EnemyPickableMemory pickableMemory)
        {
            this.mover          = mover;
            this.handController = handController;
            this.enemyMemory    = enemyMemory;
            this.pickableMemory = pickableMemory;

            topLeft   = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0));
            downRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));

            roamingTarget = GetRandomLocation();

            currentState = EnnemyState.Roaming;
        }