Пример #1
0
    // At the start of the game..
    void Start()
    {
        // Assign the Rigidbody component to our private rb variable
        rb = GetComponent <Rigidbody>();

        switch (Application.platform)
        {
        case RuntimePlatform.OSXEditor:
        case RuntimePlatform.WindowsEditor:
        case RuntimePlatform.LinuxEditor:
        case RuntimePlatform.OSXPlayer:
        case RuntimePlatform.WindowsPlayer:
        case RuntimePlatform.LinuxPlayer:
            MovementStrategy = new KeyboardStrategy();
            break;

        case RuntimePlatform.Android:
        case RuntimePlatform.IPhonePlayer:
            MovementStrategy = new AccelerometerStrategy();
            break;

        default:
            MovementStrategy = new KeyboardStrategy();
            break;
        }
    }
Пример #2
0
    public void SetStrategy(Func <MovementStrategy.Context, MovementStrategy> inst)
    {
        _currentStrategy?.OnFinish();
        var newStrategy = inst(_ctx);

        Debug.Log("Changed strategy " + _currentStrategy?.GetType() + " -> " + newStrategy.GetType());
        _currentStrategy = newStrategy;
        _currentStrategy.OnStart();
    }
 public Monster(MonsterState state, int i, int randomMonsterType, MovementStrategy[] movementStrategies)
 {
     this.TransitionTo(state);
     this.MonsterIndex   = i;
     this.CurrentHealth  = 100;
     this.Loot           = 5;
     this.Position       = i * 2 - 20;
     this.MonsterType    = randomMonsterType;
     this.MovementMethod = movementStrategies[randomMonsterType - 1];
 }
        public IStrategy Get(MovementStrategy MOVEMENT_STRATEGY)
        {
            switch (MOVEMENT_STRATEGY)
            {
            case MovementStrategy.RANDOM:
                return(new RandomStrategy());

            default:
                throw new Exception("Uknown strategy");
            }
        }
Пример #5
0
        public override void Tick()
        {
            base.Tick();

            Debug.Log("Moving creature in tick...", "MOVEMENT");
            MovementStrategy.Move();

            CheckReproduction();
            CheckFood();
            CheckDeath();
        }
        public static List <Monster> GetMockedList()
        {
            Random rnd = new Random();
            var    movementStrategies = new MovementStrategy[] { new GroundMovement(), new UnderGroundMovement(), new AirMovement() };
            var    monsters           = new List <Monster>();

            for (int i = 1; i <= 10; i++)
            {
                int randomMonsterType = rnd.Next(1, 4);
                monsters.Add(new Monster(new Alive(), i, randomMonsterType, movementStrategies));
            }
            return(monsters);
        }
Пример #7
0
 public Entity(Vector2 position, int health, bool speed, GameSprite sprite, ContentManager content, MovementStrategy movement, ShootingStrategy shooting)
 {
     this.position = position;
     this.health   = health;
     this.speed    = speed;
     this.Texture  = sprite.texture;
     this.sprite   = sprite;
     this.content  = content;
     //creating a new instance of the movements class so all the character classes inherits from this doesn't have a create a new instance every time
     characterMovements = movement;
     characterShooting  = shooting;
     isAlive            = true;
 }
Пример #8
0
    void Start()
    {
        speed = Random.Range(minSpeed, maxSpeed);

        var myTrajectory = (Trajectories)Random.Range(0, 3);

        switch (myTrajectory)
        {
        case Trajectories.LINE:
            movementStrategy = MoveLinear;
            break;

        case Trajectories.SQUARE:
            movementStrategy = MoveSquare;
            break;

        case Trajectories.SIN:
            movementStrategy = MoveSin;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Пример #9
0
 public Boss(Vector2 position, Vector2 end, int health, bool speed, GameSprite sprite, ContentManager content, MovementStrategy movement, ShootingStrategy shooting) : base(position, health, speed, sprite, content, movement, shooting)
 {
     position   = new Vector2(0, 0);
     health     = 25;
     speed      = false;
     start.X    = sprite.position.X; //setting up enemy start point
     start.Y    = sprite.position.Y; //setting up enemy start point
     this.end.X = end.X;             //setting up enemy start point
     this.end.Y = end.Y;             //setting up enemy start point
 }
 public Elevator(MovementStrategy movementStrategy)
     : base(movementStrategy)
 {
 }
 protected Vehicle(MovementStrategy strategy)
 {
     this.movementStrategy = strategy;
 }
 public Car(MovementStrategy movementStrategy)
     : base(movementStrategy)
 {
 }
Пример #13
0
 public FinalBoss(Vector2 position, Vector2 end, int fHealth, bool speed, GameSprite sprite, Texture2D newBulletTexture, ContentManager content, MovementStrategy movement, ShootingStrategy shooting) : base(position, end, fHealth, speed, sprite, content, movement, shooting)
 {
     position      = new Vector2(0, 0);
     health        = fHealth;
     speed         = false;
     start.X       = sprite.position.X; //setting up enemy start point
     start.Y       = sprite.position.Y; //setting up enemy start point
     this.end.X    = end.X;             //setting up enemy start point
     this.end.Y    = end.Y;             //setting up enemy start point
     bulletTexture = newBulletTexture;
 }
Пример #14
0
        public Player(Vector2 position, int pHealth, bool speedMode, GameSprite sprite, Texture2D bulletTexture, ContentManager content, MovementStrategy movement, ShootingStrategy shooting) : base(position, pHealth, speedMode, sprite, content, movement, shooting)
        {
            if (speed)
            {
                speedRate = 5;
            }
            else
            {
                speedRate = 10;
            }

            health = pHealth;

            this.bulletTexture      = bulletTexture;
            this.characterMovements = movement;
            this.characterShooting  = shooting;
        }
Пример #15
0
        public Player(Vector2 startPos, Vector2 endPos, int pHealth, bool speedMode, GameSprite sprite, Texture2D bulletTexture, ContentManager content, MovementStrategy movement, ShootingStrategy shooting) : base(startPos, pHealth, speedMode, sprite, content, movement, shooting)
        {
            powerUpActivated = false;
            if (speed)
            {
                speedRate = 5;
            }
            else
            {
                speedRate = 10;
            }

            health                  = pHealth;
            this.bulletTexture      = bulletTexture;
            this.characterMovements = movement;
            this.characterShooting  = shooting;
            inDanger                = false;
        }