Exemplo n.º 1
0
        public void TestCreepState()
        {
            var state = new CreepState();

            state.SetVulnerabilityWithValue(TowerType.Ice, 1000f);
            Assert.AreEqual(Vulnerability.Sudden, state.GetVulnerability(TowerType.Ice));
        }
Exemplo n.º 2
0
 private void Hold()
 {
     activeOrder    = CreepState.Hold;
     targetPosition = myPosition.position;
     targetVictim   = null;
     TryFindTarget();
 }
Exemplo n.º 3
0
 private void Stop()
 {
     activeOrder = CreepState.Idle;
     legs.Stop();
     targetVictim = null;
     TryFindTarget();
 }
Exemplo n.º 4
0
    //
    // Приказы
    //

    private void Move(DTRMVector2 position)
    {
        activeOrder         = CreepState.Move;
        targetPosition      = position;
        legs.targetPosition = targetPosition;
        targetVictim        = null;
    }
Exemplo n.º 5
0
 private void MoveAttack(DTRMVector2 position)
 {
     activeOrder    = CreepState.MoveAttack;
     targetPosition = position;
     targetVictim   = null;
     FindTargetOrCarryOn();
 }
Exemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            var elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            //Falls der Gegner noch in Bewegung ist, und auch noch Wegpunkte vor sich
            if ((creepState == CreepState.Running) && (WayPoints != null) && (WayPoints.Count > 0))
            {
                //Falls er einen Wegpunkt erreicht hat
                if (AtDestination)
                {
                    //Nächsten Wegpunkte zum aktuellen machen
                    WayPoints.Dequeue();
                    //Und die Gridposition richtig setzen
                    GridPosition.X = (float)Math.Round(GridPosition.X, 0, MidpointRounding.AwayFromZero);
                    GridPosition.Y = (float)Math.Round(GridPosition.Y, 0, MidpointRounding.AwayFromZero);
                    //Auch die Punkte müssen neu berechnet werden, da ein Creep kurz vor Ende seiner Reise mehr Punkte gibt
                    Points = (int)Math.Round(InitialHealth * maxMoveSpeed / (WayPoints.Count + 1), MidpointRounding.AwayFromZero) + 1;
                }
                else
                {
                    //Blablabla, einfach die aktuelle Geschwindikeit errechnen
                    float previousMoveSpeed = moveSpeed;
                    float desiredMoveSpeed  = FindMaxMoveSpeed(WayPoints.Peek());
                    moveSpeed = MathHelper.Clamp(desiredMoveSpeed, previousMoveSpeed - MaxMoveSpeedDelta * elapsedTime,
                                                 previousMoveSpeed + MaxMoveSpeedDelta * elapsedTime);

                    //Hier wird der Creep noch in die richtige Richtung gedreht
                    var facingDirection = (float)Math.Atan2(direction.Y, direction.X);
                    facingDirection = TurnToFace(GridPosition, WayPoints.Peek(), facingDirection,
                                                 MaxAngularVelocity * elapsedTime);
                    direction = new Vector2((float)Math.Cos(facingDirection), (float)Math.Sin(facingDirection));
                    Rotation  = (float)Math.Atan2(direction.Y, direction.X);

                    //Und die Position aktualisiert
                    GridPosition = GridPosition + (direction * moveSpeed * elapsedTime);
                }
                //Jetzt noch die "richtige" Position ausrechnen, also die, die zum Zeichnen benötigt wird
                Position =
                    new Vector2(
                        GridPosition.X * GameScreen.LevelManager.GridSize.X + GameScreen.LevelManager.GridSize.X / 2,
                        GridPosition.Y * GameScreen.LevelManager.GridSize.Y + GameScreen.LevelManager.GridSize.Y / 2);
            }
            //SInd wir am Ende des levels?
            if (TargetReached)
            {
                creepState = CreepState.Out;
                GameScreen.CreepOut(this);
            }

            //Das CustomUpdate für die Türme...
            if (CustomUpdate != null)
            {
                CustomUpdate(this, gameTime);
            }

            HealthPosition = new Vector2(Position.X - HealthSize.X / 2, Position.Y - Size.Y);

            base.Update(gameTime);
        }
Exemplo n.º 7
0
		public void TestMeltState()
		{
			var creep = new Creep(CreepType.Cloth, Vector2D.Zero);
			var state = new CreepState();
			state.Melt = true;
			state.UpdateStateAndTimers(creep);
			Assert.IsTrue(state.Melt);
		}
Exemplo n.º 8
0
 private void Patrol(DTRMVector2 position)
 {
     targetPosition = position;
     patrolPosition = myPosition.position;
     activeOrder    = CreepState.Patrol;
     targetVictim   = null;
     FindTargetOrCarryOn();
 }
Exemplo n.º 9
0
    void Start()
    {
        state = CreepState.Running;

        if (GameMasterObject.playerUse != null)
        {
            player = GameMasterObject.playerUse.transform;
        }
    }
Exemplo n.º 10
0
        public void TestMeltState()
        {
            var creep = new Creep(CreepType.Cloth, Vector2D.Zero);
            var state = new CreepState();

            state.Melt = true;
            state.UpdateStateAndTimers(creep);
            Assert.IsTrue(state.Melt);
        }
Exemplo n.º 11
0
    void UpdateTarget(Transform targ)
    {
        target   = targ;
        opponent = targ.GetComponent <Pleb>();

        if (Vector3.Distance(myTransform.position, targ.position) <= closeEnough)
        {
            state = CreepState.Fighting;
        }
    }
Exemplo n.º 12
0
 void Awake()
 {
     seeker     = GetComponent <Seeker>();
     controller = GetComponent <CharacterController>();
     creepState = CreepState.Idle;
     //heading = Random.Range(0, 360);
     radius = 5;
     //controller.detectCollisions = false;
     animation.Play("idle");
     //GetComponent<ShadowComponent>().CreateShadowPlane();
 }
Exemplo n.º 13
0
		public void TestSlowImmuneState()
		{
			var creep = new Creep(CreepType.Cloth, Vector2D.Zero);
			var state = new CreepState();
			state.Slow = true;
			state.UpdateStateAndTimers(creep);
			Assert.IsTrue(state.Slow);
			state.SlowImmune = true;
			state.UpdateStateAndTimers(creep);
			Assert.IsTrue(state.SlowImmune);
		}
Exemplo n.º 14
0
		public void TestFrozenState()
		{
			var creep = new Creep(CreepType.Cloth, Vector2D.Zero);
			var state = new CreepState();
			state.Frozen = true;
			state.UpdateStateAndTimers(creep);
			Assert.IsTrue(state.Frozen);
			state.Unfreezable = true;
			state.UpdateStateAndTimers(creep);
			Assert.IsTrue(state.Unfreezable);
		}
Exemplo n.º 15
0
    private void Attack(Health target)
    {
        if (!attack.CheckTarget(target))
        {
            return;
        }

        activeOrder  = CreepState.Attack;
        targetVictim = target;
        attack.AppointTarget(targetVictim);
        legs.FollowTarget(target.myPosition);
    }
Exemplo n.º 16
0
        public void TestSlowImmuneState()
        {
            var creep = new Creep(CreepType.Cloth, Vector2D.Zero);
            var state = new CreepState();

            state.Slow = true;
            state.UpdateStateAndTimers(creep);
            Assert.IsTrue(state.Slow);
            state.SlowImmune = true;
            state.UpdateStateAndTimers(creep);
            Assert.IsTrue(state.SlowImmune);
        }
Exemplo n.º 17
0
        public void TestFrozenState()
        {
            var creep = new Creep(CreepType.Cloth, Vector2D.Zero);
            var state = new CreepState();

            state.Frozen = true;
            state.UpdateStateAndTimers(creep);
            Assert.IsTrue(state.Frozen);
            state.Unfreezable = true;
            state.UpdateStateAndTimers(creep);
            Assert.IsTrue(state.Unfreezable);
        }
Exemplo n.º 18
0
		private void CreateStats(CreepType type, CreepPropertiesXml properties)
		{
			CreepData creepData = properties.Get(type);
			Name = creepData.Name;
			CreateStat("Hp", creepData.MaxHp);
			CreateStat("Speed", creepData.Speed);
			CreateStat("Resistance", creepData.Resistance);
			CreateStat("Gold", creepData.GoldReward);
			if (Player.Current != null)
				ApplyBuff(new BuffEffect(Player.Current.Avatar.GetType().Name + "GoldMultiplier"));
			State = new CreepState();
			foreach (var modifier in creepData.TypeDamageModifier)
				State.SetVulnerabilityWithValue(modifier.Key, modifier.Value);
		}
Exemplo n.º 19
0
    //
    // IAttackListener
    //

    public void OnLostAppointedTarget()
    {
        targetVictim = null;

        switch (activeOrder)
        {
        case CreepState.Idle:

            if (!TryFindTarget())
            {
                legs.Stop();
            }

            break;

        case CreepState.Hold:

            FindTargetOrCarryOn();
            break;

        case CreepState.Move:

            Debug.LogWarning("Unexpected lost appointed target event for move state!");
            break;

        case CreepState.MoveAttack:

            FindTargetOrCarryOn();
            break;

        case CreepState.Attack:

            activeOrder = CreepState.Idle;
            TryFindTarget();

            break;

        case CreepState.Patrol:

            FindTargetOrCarryOn();
            break;


        default:
            Debug.LogError("Unknown order!");
            break;
        }
    }
Exemplo n.º 20
0
    void Update()
    {
        RaycastHit opponentHit;

        if (state == CreepState.Running)
        {
        }
        else
        {
            agent.isStopped = true;
        }

        if (opponent == null)
        {
            Ray middleMiddleRay = new Ray(myTransform.position, myTransform.forward);
            if (Physics.SphereCast(middleMiddleRay, sphereRadius, out opponentHit, lookRayDistance, lookLayerMask))
            {
                state = CreepState.Idle;
                UpdateTarget(opponentHit.collider.transform);
            }
        }

        #region Switch statment To check states

        switch (state)
        {
        case CreepState.Idle:
            break;

        case CreepState.Searching:
            break;

        case CreepState.Running:
            break;

        case CreepState.Fighting:
            break;

        case CreepState.Dead:
            break;

        default:
            break;
        }

        #endregion
    }
Exemplo n.º 21
0
 public override void Initialize()
 {
     SpriteBatch      = CurrGame.SpriteBatch;
     TextureDirectory = "Creep/";
     OriginType       = OriginType.Center;
     Size             = new Vector2(GameScreen.LevelManager.GridSize.X * 1.5f, GameScreen.LevelManager.GridSize.Y);
     HealthSize       = new Vector2(Size.X, 5);
     HealthPosition   = new Vector2(Position.X - HealthSize.X / 2, Position.Y - Size.Y);
     spriteBatch      = CurrGame.SpriteBatch;
     Position         =
         new Vector2(GridPosition.X * GameScreen.LevelManager.GridSize.X + GameScreen.LevelManager.GridSize.X / 2,
                     GridPosition.Y * GameScreen.LevelManager.GridSize.Y + GameScreen.LevelManager.GridSize.Y / 2);
     //Weg zum Ziel suchen
     GridChanged(null);
     Points     = (int)Math.Round(InitialHealth * maxMoveSpeed / WayPoints.Count, MidpointRounding.AwayFromZero);
     creepState = CreepState.Running;
     base.Initialize();
 }
Exemplo n.º 22
0
        protected override void RestartStatsAndState(float percentage, AgentData data)
        {
            var creepData = (CreepData)data;

            Stats.Clear();
            CreateStat("Hp", creepData.MaxHp);
            var amountToSubtract = (1 - percentage) * creepData.MaxHp;

            AdjustStat(new StatAdjustment("Hp", "", -amountToSubtract));
            CreateStat("Speed", creepData.Speed);
            CreateStat("Resistance", creepData.Resistance);
            CreateStat("Gold", creepData.GoldReward);
            State = new CreepState();
            foreach (var modifier in creepData.TypeDamageModifier)
            {
                State.SetVulnerabilityWithValue(modifier.Key, modifier.Value);
            }
        }
Exemplo n.º 23
0
        private void CreateStats(CreepType type, CreepPropertiesXml properties)
        {
            CreepData creepData = properties.Get(type);

            Name = creepData.Name;
            CreateStat("Hp", creepData.MaxHp);
            CreateStat("Speed", creepData.Speed);
            CreateStat("Resistance", creepData.Resistance);
            CreateStat("Gold", creepData.GoldReward);
            if (Player.Current != null)
            {
                ApplyBuff(new BuffEffect(Player.Current.Avatar.GetType().Name + "GoldMultiplier"));
            }
            State = new CreepState();
            foreach (var modifier in creepData.TypeDamageModifier)
            {
                State.SetVulnerabilityWithValue(modifier.Key, modifier.Value);
            }
        }
Exemplo n.º 24
0
    //
    // ILegsListener
    //

    public void OnTargetReach()
    {
        switch (activeOrder)
        {
        case CreepState.Idle:

            Debug.LogWarning("Unexpected target reach event for state Idle!");
            break;

        case CreepState.Hold:

            // Вернулись на место, отдыхаем.
            break;

        case CreepState.Move:

            activeOrder = CreepState.Idle;
            break;

        case CreepState.MoveAttack:

            activeOrder = CreepState.Idle;
            break;

        case CreepState.Attack:

            Debug.LogWarning("Unexpected target reach event for state Attack!");
            break;

        case CreepState.Patrol:

            DTRMVector2 exchangePosition = targetPosition;
            targetPosition      = patrolPosition;
            patrolPosition      = exchangePosition;
            legs.targetPosition = targetPosition;
            break;

        default:
            Debug.LogError("Unknown order!");
            break;
        }
    }
Exemplo n.º 25
0
    //
    // ILegsListener
    //
    public void OnTargetReach()
    {
        switch(activeOrder) {

            case CreepState.Idle:

                Debug.LogWarning("Unexpected target reach event for state Idle!");
                break;

            case CreepState.Hold:

                // Вернулись на место, отдыхаем.
                break;

            case CreepState.Move:

                activeOrder = CreepState.Idle;
                break;

            case CreepState.MoveAttack:

                activeOrder = CreepState.Idle;
                break;

            case CreepState.Attack:

                Debug.LogWarning("Unexpected target reach event for state Attack!");
                break;

            case CreepState.Patrol:

                DTRMVector2 exchangePosition = targetPosition;
                targetPosition = patrolPosition;
                patrolPosition = exchangePosition;
                legs.targetPosition = targetPosition;
                break;

            default:
                Debug.LogError("Unknown order!");
                break;

        }
    }
Exemplo n.º 26
0
		protected override void RestartStatsAndState(float percentage, AgentData data)
		{
			var creepData = (CreepData)data;
			Stats.Clear();
			CreateStat("Hp", creepData.MaxHp);
			var amountToSubtract = (1 - percentage) * creepData.MaxHp;
			AdjustStat(new StatAdjustment("Hp", "", -amountToSubtract));
			CreateStat("Speed", creepData.Speed);
			CreateStat("Resistance", creepData.Resistance);
			CreateStat("Gold", creepData.GoldReward);
			State = new CreepState();
			foreach (var modifier in creepData.TypeDamageModifier)
				State.SetVulnerabilityWithValue(modifier.Key, modifier.Value);
		}
Exemplo n.º 27
0
		public void TestCreepState()
		{
			var state = new CreepState();
			state.SetVulnerabilityWithValue(TowerType.Ice, 1000f);
			Assert.AreEqual(Vulnerability.Sudden, state.GetVulnerability(TowerType.Ice));
		}
Exemplo n.º 28
0
 public void Kill()
 {
     creepState = CreepState.Killed;
     GameScreen.CreepOut(this);
 }
Exemplo n.º 29
0
 void Awake()
 {
     myTransform = transform;
     state       = CreepState.Running;
     agent       = GetComponent <NavMeshAgent>();
 }
Exemplo n.º 30
0
    //
    // IAttackListener
    //
    public void OnLostAppointedTarget()
    {
        targetVictim = null;

        switch(activeOrder) {

            case CreepState.Idle:

                if (!TryFindTarget())
                    legs.Stop();

                break;

            case CreepState.Hold:

                FindTargetOrCarryOn();
                break;

            case CreepState.Move:

                Debug.LogWarning("Unexpected lost appointed target event for move state!");
                break;

            case CreepState.MoveAttack:

                FindTargetOrCarryOn();
                break;

            case CreepState.Attack:

                activeOrder = CreepState.Idle;
                TryFindTarget();

                break;

            case CreepState.Patrol:

                FindTargetOrCarryOn();
                break;

            default:
                Debug.LogError("Unknown order!");
                break;

        }
    }
Exemplo n.º 31
0
    private void Attack(Health target)
    {
        if (!attack.CheckTarget(target))
            return;

        activeOrder = CreepState.Attack;
        targetVictim = target;
        attack.AppointTarget(targetVictim);
        legs.FollowTarget(target.myPosition);
    }
Exemplo n.º 32
0
 private void Hold()
 {
     activeOrder = CreepState.Hold;
     targetPosition = myPosition.position;
     targetVictim = null;
     TryFindTarget();
 }
Exemplo n.º 33
0
 //
 // Приказы
 //
 private void Move(DTRMVector2 position)
 {
     activeOrder = CreepState.Move;
     targetPosition = position;
     legs.targetPosition = targetPosition;
     targetVictim = null;
 }
Exemplo n.º 34
0
 private void Stop()
 {
     activeOrder = CreepState.Idle;
     legs.Stop();
     targetVictim = null;
     TryFindTarget();
 }
Exemplo n.º 35
0
 private void Patrol(DTRMVector2 position)
 {
     targetPosition = position;
     patrolPosition = myPosition.position;
     activeOrder = CreepState.Patrol;
     targetVictim = null;
     FindTargetOrCarryOn();
 }
Exemplo n.º 36
0
 private void MoveAttack(DTRMVector2 position)
 {
     activeOrder = CreepState.MoveAttack;
     targetPosition = position;
     targetVictim = null;
     FindTargetOrCarryOn();
 }