Exemple #1
0
 public Behavior(Behavior b)
 {
     id = b.id;
     nextBehavior = b.nextBehavior;
     destination = b.destination;
     duration = b.duration;
     offSet = b.offSet;
     period = b.period;
     toggle = b.toggle;
     primaryValue = b.primaryValue;
     secondaryValue = b.secondaryValue;
 }
Exemple #2
0
        public int UpdateBehavior(int gameTime)
        {
            averagePosition = Vector3.Zero;
            foreach (Edge e in edges)
            {
                averagePosition += e.start.position;
            }
            averagePosition = averagePosition / 4;
            if (currentBehavior == null)
                return 0;
            currentTime += gameTime;
            if (nextBehavior == true)
            {

                foreach (Behavior b in behaviors)
                {
                    if (b.id == currentBehavior.nextBehavior)
                    {
                        if (b.duration != 0)
                        {
                            SoundFX.PlatformMove(averagePosition);
                        }
                        else if (currentBehavior.duration != 0)
                        {
                            SoundFX.PlatformStop(averagePosition);
                        }
                        currentBehavior = b;
                        break;
                    }
                }

                foreach (Edge e in edges)
                {
                    if (currentBehavior.duration != 0)
                    {
                        e.start.velocity = currentBehavior.destination / currentBehavior.duration;
                        e.end.velocity = currentBehavior.destination / currentBehavior.duration;
                    }
                    else
                    {
                        e.start.velocity = Vector3.Zero;
                        e.end.velocity = Vector3.Zero;
                    }
                }
                nextBehavior = false;
                return gameTime;
            }
            if (currentBehavior.duration > 0 && currentTime > currentBehavior.duration)
            {
                nextBehavior = true;
                int returnTime = currentBehavior.duration - (currentTime - gameTime);
                currentTime -= currentBehavior.duration;

                return returnTime;
            }
            return gameTime;
        }
Exemple #3
0
        public void UpdateBehavior()
        {
            if (currentBehavior == null)
            {
                currentBehavior = behaviors[0];

                if (currentBehavior.destination != Vector3.Zero)
                {
                    foreach (Edge e in edges)
                    {
                        if (currentBehavior.duration != 0)
                        {
                            e.start.velocity = currentBehavior.destination / currentBehavior.duration;
                            e.end.velocity = currentBehavior.destination / currentBehavior.duration;
                        }
                    }
                    currentTime = 0;
                }
            }
        }
Exemple #4
0
        public Doodad(VL.DoodadType type, Vector3 position, Vector3 normal, Vector3 direction)
        {
            id = "d_"+type.ToString();
            srcDoodad = this;
            this.type = type;
            this.position = new Vertex(position, normal, Vector3.Zero, direction);
            this.spawnPosition = new Vertex(position, normal, Vector3.Zero, direction);
            behaviors = new List<Behavior>();
            currentBehavior = null;
            if (type == VL.DoodadType.LeftDoor || type == VL.DoodadType.RightDoor)
                stateTransition = 0;

            if (isOrb)
                active = true;
        }
Exemple #5
0
        public void SetBehavior(Behavior b)
        {
            if (b.duration != 0)
            {
                SoundFX.PlatformMove(averagePosition);
            }
            else if (currentBehavior.duration != 0)
            {
                SoundFX.PlatformStop(averagePosition);
            }

            currentBehavior = b;

            currentTime = 0;
            nextBehavior = false;

            foreach (Edge e in edges)
            {
                if (currentBehavior.duration != 0)
                {
                    e.start.velocity = currentBehavior.destination / currentBehavior.duration;
                    e.end.velocity = currentBehavior.destination / currentBehavior.duration;
                }
                else
                {
                    e.start.velocity = Vector3.Zero;
                    e.end.velocity = Vector3.Zero;
                }
            }
        }
Exemple #6
0
        public Doodad(VL.Doodad xmlDoodad, Vector3 normal)
        {
            srcDoodad = this;
            this.type = xmlDoodad.type;
            this.id = xmlDoodad.IDString;
            this.targetBehavior = xmlDoodad.targetBehavior;
            this.targetObject = xmlDoodad.targetObject;
            this.expectedBehavior = xmlDoodad.expectBehavior;
            this.activationCost = xmlDoodad.activationCost;

            this.abilityType = (AbilityType)xmlDoodad.ability;
            this.originalAbilityType = (AbilityType)xmlDoodad.ability;
            this.position = new Vertex(xmlDoodad.position, normal, Vector3.Zero, xmlDoodad.up);
            this.spawnPosition = new Vertex(xmlDoodad.position, normal, Vector3.Zero, xmlDoodad.up);
            behaviors = new List<Behavior>();
            currentBehavior = null;

            if (isOrb)
                active = true;
            if (type == VL.DoodadType.BluePowerStation)
                orbsRemaining = 1;
            if (type == VL.DoodadType.RedPowerStation)
                orbsRemaining = 1;

            if (type == VL.DoodadType.WallSwitch)
                stateTransition = 0;
            if (isStation)
                stateTransition = 0;
        }
Exemple #7
0
        public void UpdateBehavior()
        {
            if (currentBehavior == null)
            {
                currentBehavior = behaviors[0];
                currentBehaviorId = currentBehavior.id;
                if (currentBehavior.offSet == 0)
                {
                    //properties.primaryValue = currentBehavior.primaryValue;
                    //properties.secondaryValue = currentBehavior.secondaryValue;
                    toggleOn = currentBehavior.toggle;
                    if (toggleOn == true)
                        stateTransition = 1;
                    else
                        stateTransition = 0;

                    behaviorStarted = true;
                }
            }
        }
Exemple #8
0
        public int UpdateBehavior(int gameTime)
        {
            if (currentBehavior == null)
                return 0;
            currentTime += gameTime;
            if (behaviorStarted == false && currentTime > currentBehavior.offSet)
            {
                //properties.primaryValue = currentBehavior.primaryValue;
                //properties.secondaryValue = currentBehavior.secondaryValue;
                if (currentBehavior.toggle)
                    Activate();
                else
                    Deactivate();
                currentTime -= currentBehavior.offSet;
                behaviorStarted = true;
                nextBehavior = false;
            }
            if (nextBehavior == true && behaviorStarted == true)
            {
                behaviorStarted = true;
                foreach (Behavior b in behaviors)
                {
                    if (b.id == currentBehavior.nextBehavior)
                    {
                        BehaviorChange(currentBehavior, b);
                        currentBehavior = b;
                        currentBehaviorId = currentBehavior.id;
                        break;
                    }
                }
                //properties.primaryValue = currentBehavior.primaryValue;
                //properties.secondaryValue = currentBehavior.secondaryValue;
                if (currentBehavior.toggle)
                    Activate();
                else
                    Deactivate();

                nextBehavior = false;
                return gameTime;
            }
            if (behaviorStarted)
            {
                if (currentBehavior.duration != 0 && currentTime > currentBehavior.duration)
                {
                    nextBehavior = true;
                    currentTime -= currentBehavior.duration;
                    return currentBehavior.duration - (currentTime - gameTime);
                }
                if (currentBehavior.period != 0 && currentTime > currentBehavior.period)
                {
                    currentTime -= currentBehavior.period;
                    if (toggleOn)
                        Deactivate();
                    else
                        Activate();
                }
            }
            return gameTime;
        }
Exemple #9
0
 public void SetBehavior(Behavior b)
 {
     BehaviorChange(currentBehavior, b);
     currentBehavior = b;
     currentBehaviorId = currentBehavior.id;
     if (currentBehavior.toggle)
         Activate();
     else
         Deactivate();
     //toggleOn = currentBehavior.toggle;
     currentTime = 0;
     nextBehavior = false;
 }
Exemple #10
0
 public void BehaviorChange(Behavior b1, Behavior b2)
 {
     if (type == VL.DoodadType.Door)
     {
         if (b1.toggle != b2.toggle)
         {
             SoundFX.OpenDoor(position.position);
         }
     }
     if (type == VL.DoodadType.Beam && styleSpriteIndex == 0)
     {
         if (b1.toggle != b2.toggle)
         {
             if(b1.toggle)
                 SoundFX.ElectricOn(position.position);
             else
                 SoundFX.ElectricOff(position.position);
         }
     }
     if (type == VL.DoodadType.Beam && styleSpriteIndex == 1)
     {
         if (b1.toggle != b2.toggle)
         {
             if (b1.toggle)
                 SoundFX.FlameOn(position.position);
             else
                 SoundFX.FlameOff(position.position);
         }
     }
 }