Esempio n. 1
0
 internal static void SetThingStateInt(Thing thing, ThingState value)
 {
     if (_thingStateInt == null)
     {
         _thingStateInt = typeof(Thing).GetField("thingStateInt", BindingFlags.Instance | BindingFlags.NonPublic);
     }
     _thingStateInt.SetValue(thing, value);
 }
Esempio n. 2
0
 internal static void SetThingStateInt(Thing thing, ThingState value)
 {
     if (_thingStateInt == null)
     {
         _thingStateInt = typeof(Thing).GetField("thingStateInt", BindingFlags.Instance | BindingFlags.NonPublic);
     }
     _thingStateInt.SetValue(thing, value);
 }
Esempio n. 3
0
        /// <summary>
        /// Enqueue a new destination for the unit to move towards
        /// </summary>
        public void AddDestination(Vector3 a_newDestination)
        {
            if (m_thingState != ThingState.BeingBuilt)
            {
                //change unit state to moving
                m_thingState = ThingState.Moving;

                //enqueue
                m_destination.Add(a_newDestination);
            }
        }
Esempio n. 4
0
        public void ChangeDestination(List <Vector3> a_newDestinationList)
        {
            if (m_thingState != ThingState.BeingBuilt)
            {
                //change unit state to moving
                m_thingState = ThingState.Moving;

                //clear and enqueue
                m_destination = a_newDestinationList;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Returns true when it's finished being built
        /// </summary>
        public bool BuildMe(float a_elapsedTime)
        {
            if (m_builtTimer < m_requiredBuildTime)
            {
                //Then timer ticks upwards closer to ze destiny!
                m_builtTimer += a_elapsedTime;
                HPBuffer     += m_HPhealFactor * m_maxHP * a_elapsedTime;
                //i++ to continue to next thingy

                return(false);
            }
            else
            {
                m_thingState = ThingState.Idle;
                return(true);
            }
        }
Esempio n. 6
0
        public Thing(byte a_id, Model a_model, bool a_IsUnit, int a_hp, int a_maxHP, Vector3 a_position, float a_buildTime, int a_supplyValue, int a_price, addUnderAttackPosition a_function)
        {
            m_ownerID = a_id;

            m_isUnit = a_IsUnit;

            m_exists = true;
            m_alive  = true;
            m_model  = a_model;
            m_maxHP  = a_maxHP;
            HP       = a_hp;

            m_price = a_price;

            if (a_buildTime > 0)
            {
                m_HPhealFactor = 0.9f * (1 / a_buildTime);
            }
            else
            {
                m_hp = 1;
            }

            m_underAttackFunction = a_function;

            m_thingState = ThingState.BeingBuilt;

            m_currentposition = a_position;

            m_requiredBuildTime = a_buildTime;

            m_supplyValue = a_supplyValue;
            if (m_supplyValue < 0)
            {
                m_supplyValue = 0;
            }

            //initiate actionboxes
            for (int y = 0; y < m_actionbox.GetLength(1); y++)
            {
                for (int x = 0; x < m_actionbox.GetLength(0); x++)
                {
                    m_actionbox[x, y] = new ObjectAction();
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Does attack behavior, if no attackTarget, Seek for one. If there is one, attack!
        /// </summary>
        public void DoAttackBehavior(List <Player> a_players, PathFinder a_pathfinder, ViewClasses.iParticles a_particleHandler, float a_elapsedTime)
        {
            Cooldown(a_elapsedTime);

            if (m_attacker.m_thingState == ThingState.Hold || m_attacker.m_thingState == ThingState.Hunting)
            {
                m_baseState = m_attacker.m_thingState;
            }

            //All the stuff you can't be when attacking.
            if (m_attacker.m_thingState != ThingState.Moving && m_attacker.m_thingState != ThingState.Building)
            {
                foreach (Player player in a_players)
                {
                    Seek(player);
                }

                //if you have no target
                if (m_target == null)
                {
                    if (m_attacker.m_currentposition != m_huntingPosition && m_baseState == ThingState.Hunting)
                    {
                        StartHunting(m_huntingPosition, a_pathfinder);
                    }
                    else if (m_attacker.m_currentposition == m_huntingPosition && m_baseState == ThingState.Hunting)
                    {
                        m_baseState = ThingState.Idle;
                    }

                    m_absoluteTarget = false;
                }//if you doo!
                else
                {
                    Attack(a_pathfinder, a_particleHandler);
                }
            }
        }
Esempio n. 8
0
 public void UnsetTarget()
 {
     m_target         = null;
     m_absoluteTarget = false;
     m_baseState      = ThingState.Idle;
 }
 private void UpdateState()
 {
     ThingState next = state.Act ();
     if (next != state) {
         Debug.LogFormat ("{0}: {1} -> {2}", name, state.GetType ().Name, next, GetType ().Name);
         state = state.Act ();
     }
 }
Esempio n. 10
0
 void Start()
 {
     thing = GetComponent<MeshRenderer> ();
     highlighter = GetComponent<ThingHighlighter> ();
     // Initialize "Done" sparks
     myDoneSparks = Instantiate (prefabDoneSparks, transform.position, prefabDoneSparks.transform.rotation) as ParticleSystem;
     myDoneSparks.name = "DoneSparks";
     myDoneSparks.transform.SetParent (transform);
     myDoneSparks.transform.Translate (Vector3.up * GetComponent<MeshRenderer>().bounds.extents.y, Space.World);
     // Initialize Progress text
     progressTextMesh = Instantiate (prefabProgressText, transform.position, prefabProgressText.transform.rotation) as TextMesh;
     progressTextMesh.name = "ProgressText";
     progressTextMesh.transform.SetParent (transform);
     progressTextMesh.transform.Translate (Vector3.up * GetComponent<MeshRenderer>().bounds.extents.y, Space.World);
     // Set initial progress
     progress = initialProgress;
     initialColor = color;
     state = new NormalState (this);
 }
 public static Extension AddStateAsExtension(this IExtendable extendable, ThingState state)
 {
     return(extendable.AddStringAsExtension(HealthVaultExtensions.StateFhirExtensionName, state.ToString()));
 }
Esempio n. 12
0
 public ThingStateChangedMessage(string id, ThingState newState)
 {
     Id       = id;
     NewState = newState;
 }
 public static bool IsInitialized(this ThingState state)
 {
     return((int)state >= (int)ThingState.Initialized);
 }