Exemple #1
0
        // Executes procedure for performing an attack
        private void Attack(Weapon weapon)
        {
            // Set velocity only as a direction vector
            Velocity = Target.Position - Position;
            Velocity.Normalize();
            // Face towards target with no heuristic
            EntityOrientationState originalState = OrState;

            OrState = EntityOrientationState.None;
            SetOrientation(Target.Position - Position);
            OrState = originalState;

            if (lastAttackTime > weapon.Speed)
            {
                AttackFunction(this, weapon);
                DoFuzzyLogic();
                lastAttackTime = 0;
            }
        }
        // Executes procedure for performing an attack
        private void Attack(Weapon weapon)
        {
            // Set velocity only as a direction vector
            Velocity = Target.Position - Position;
            Velocity.Normalize();
            // Face towards target with no heuristic
            EntityOrientationState originalState = OrState;
            OrState = EntityOrientationState.None;
            SetOrientation(Target.Position - Position);
            OrState = originalState;

            if (lastAttackTime > weapon.Speed)
            {
                AttackFunction(this, weapon);
                DoFuzzyLogic();
                lastAttackTime = 0;
            }
        }
        public Zombie(int health, int maxHealth, ZombieType type, ref Model modelwalk, ref Model modelatt, ref Model modelhurt, ref Model modeldie, Action<Entity, Entity> attackFunction, Func<Vector3, Vector3, PathFinding.Node> astarGetter)
            : base()
        {
            this.astarGetter = astarGetter;
            this.model = modelwalk;
            this.HealthPoints = health;
            this.MaxHealth = maxHealth;

            this.MaxVelocity = 0.04f;
            this.MaxAcceleration = 0.04f;
            if (type == ZombieType.Boss)
            {
                this.MaxVelocity *= 2;
                this.MaxAcceleration *= 2;
                this.modelRadius *= 2;
            }
            ArriveRadius = 1;
            FleeRadius = 30;
            TimeToTarget = 0.070f;
            RotationTimeToTarget = 0.00025f;
            InterpolationSpeed = 10;
            TargetRotation = 0.02f;
            SlowRotationThreshold = (float)Math.PI;
            SlowRadiusThreshold = (float)Math.PI * 3;
            MaxRotationSpeed = (float)Math.PI / 12;
            MaxRotationAcceleration = (float)Math.PI;

            PosState = EntityPositionState.SteeringWander;
            OrState = EntityOrientationState.Face;
            BehaviouralState = BehaviourState.Wander;

            zombieType = type;
            MeleeAttack = new Weapon(WeaponType.ZombieHands);
            RangedAttack = new Weapon(WeaponType.Vomit);
            if (type == ZombieType.Boss)
            {
                MeleeAttack.FirePower *= 2;
                RangedAttack.FirePower *= 2;
            }
            this.AttackFunction = attackFunction;
            lastAttackTime = 0;

            // Look up our custom skinning information. for walking
            skinningDatawalk = (SkinningData)modelwalk.Tag;

            if (skinningDatawalk == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");

            // Create an animation player, and start decoding an animation clip.
            animationPlayerwalk = new AnimationPlayer(skinningDatawalk);
            clipwalk = skinningDatawalk.AnimationClips["Take 001"];
            animationPlayerwalk.StartClip(clipwalk);

            // Look up our custom skinning information. for dying
            skinningDatadie = (SkinningData)modeldie.Tag;

            if (skinningDatadie == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");

            // Create an animation player, and start decoding an animation clip.
            animationPlayerdie = new AnimationPlayer(skinningDatadie);
            clipdie = skinningDatadie.AnimationClips["Take 001"];
            animationPlayerdie.StartClip(clipdie);

            // Look up our custom skinning information. for attacking
            skinningDataattack = (SkinningData)modelatt.Tag;

            if (skinningDataattack == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");

            // Create an animation player, and start decoding an animation clip.
            animationPlayerattack = new AnimationPlayer(skinningDataattack);
            clipattack = skinningDataattack.AnimationClips["Take 001"];
            animationPlayerattack.StartClip(clipattack);

            // Look up our custom skinning information. for hurting
            skinningDatahurt = (SkinningData)modelhurt.Tag;

            if (skinningDatahurt == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");

            // Create an animation player, and start decoding an animation clip.
            animationPlayerhurt = new AnimationPlayer(skinningDatahurt);
            cliphurt = skinningDatahurt.AnimationClips["Take 001"];
            animationPlayerhurt.StartClip(cliphurt);
        }
Exemple #4
0
        public Zombie(int health, int maxHealth, ZombieType type, ref Model modelwalk, ref Model modelatt, ref Model modelhurt, ref Model modeldie, Action <Entity, Entity> attackFunction, Func <Vector3, Vector3, PathFinding.Node> astarGetter)
            : base()
        {
            this.astarGetter  = astarGetter;
            this.model        = modelwalk;
            this.HealthPoints = health;
            this.MaxHealth    = maxHealth;

            this.MaxVelocity     = 0.04f;
            this.MaxAcceleration = 0.04f;
            if (type == ZombieType.Boss)
            {
                this.MaxVelocity     *= 2;
                this.MaxAcceleration *= 2;
                this.modelRadius     *= 2;
            }
            ArriveRadius            = 1;
            FleeRadius              = 30;
            TimeToTarget            = 0.070f;
            RotationTimeToTarget    = 0.00025f;
            InterpolationSpeed      = 10;
            TargetRotation          = 0.02f;
            SlowRotationThreshold   = (float)Math.PI;
            SlowRadiusThreshold     = (float)Math.PI * 3;
            MaxRotationSpeed        = (float)Math.PI / 12;
            MaxRotationAcceleration = (float)Math.PI;

            PosState         = EntityPositionState.SteeringWander;
            OrState          = EntityOrientationState.Face;
            BehaviouralState = BehaviourState.Wander;

            zombieType   = type;
            MeleeAttack  = new Weapon(WeaponType.ZombieHands);
            RangedAttack = new Weapon(WeaponType.Vomit);
            if (type == ZombieType.Boss)
            {
                MeleeAttack.FirePower  *= 2;
                RangedAttack.FirePower *= 2;
            }
            this.AttackFunction = attackFunction;
            lastAttackTime      = 0;

            // Look up our custom skinning information. for walking
            skinningDatawalk = (SkinningData)modelwalk.Tag;

            if (skinningDatawalk == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayerwalk = new AnimationPlayer(skinningDatawalk);
            clipwalk            = skinningDatawalk.AnimationClips["Take 001"];
            animationPlayerwalk.StartClip(clipwalk);


            // Look up our custom skinning information. for dying
            skinningDatadie = (SkinningData)modeldie.Tag;

            if (skinningDatadie == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayerdie = new AnimationPlayer(skinningDatadie);
            clipdie            = skinningDatadie.AnimationClips["Take 001"];
            animationPlayerdie.StartClip(clipdie);


            // Look up our custom skinning information. for attacking
            skinningDataattack = (SkinningData)modelatt.Tag;

            if (skinningDataattack == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayerattack = new AnimationPlayer(skinningDataattack);
            clipattack            = skinningDataattack.AnimationClips["Take 001"];
            animationPlayerattack.StartClip(clipattack);

            // Look up our custom skinning information. for hurting
            skinningDatahurt = (SkinningData)modelhurt.Tag;

            if (skinningDatahurt == null)
            {
                throw new InvalidOperationException
                          ("This model does not contain a SkinningData tag.");
            }

            // Create an animation player, and start decoding an animation clip.
            animationPlayerhurt = new AnimationPlayer(skinningDatahurt);
            cliphurt            = skinningDatahurt.AnimationClips["Take 001"];
            animationPlayerhurt.StartClip(cliphurt);
        }