public bool GetRandomResult(AIBehaviors fsm, out BaseState resultState, float randomValue)
    {
        resultState = null;

        if ( states.Length > 0 )
        {
            float totalWeight = 1.0f;

            for ( int i = 0; i < states.Length; i++ )
            {
                if ( randomValue > totalWeight - weights[i] )
                {
                    resultState = states[i];
                    return true;
                }

                totalWeight -= weights[i];
            }

            resultState = states[states.Length - 1];
            return true;
        }
        else
        {
            Debug.LogWarning("The 'Go To Random State Trigger' requires at least 1 possible state!");
        }

        return false;
    }
Пример #2
0
        public HexNumericUpDown()
        {
            InitializeComponent();

            _state = BaseState.hex;

        }
    public static BaseState DrawEnabledStatePopup(AIBehaviors fsm, BaseState curState)
    {
        List<string> statesList = new List<string>();
        Dictionary<string, BaseState> statesDictionary = new Dictionary<string, BaseState>();
        BaseState[] states = fsm.GetAllStates();
        string[] stateSelections;
        int selection = 0;

        // Get the state names
        for ( int i = 0; i < fsm.stateCount; i++ )
        {
            // Should we include state i in the list?
            if ( states[i].isEnabled )
            {
                string stateName = states[i].name;

                statesList.Add(stateName);
                statesDictionary[stateName] = states[i];

                if ( states[i] == curState )
                {
                    selection = statesList.Count-1;
                }
            }
        }
        stateSelections = statesList.ToArray();

        selection = EditorGUILayout.Popup(selection, stateSelections);

        return statesDictionary[stateSelections[selection]];
    }
Пример #4
0
    public void ChangeState(string stateName)
    {
        System.Type t = System.Type.GetType(stateName);

        state.Destruct();
        state = gameObject.AddComponent(t) as BaseState;
        state.Construct();
    }
Пример #5
0
	public void ChangeState(int newState)
	{
		BaseState previous = _currentState;
		previous.OnExit();
		
		BaseState next = _allStates[newState];
		next.OnEnter();
		
		_currentState = next;
	}
Пример #6
0
 public void ChangeState(BaseState newState)
 {
     // Exit current state
       if (currentState)
      currentState.Exit();
       // Assign new state
       currentState = newState;
       // Enter new state
       currentState.Enter(this);
 }
Пример #7
0
        /// <summary>
        /// Configure all the slot states.
        /// </summary>
        /// <param name="stateMachine">The game state machine.</param>
        public override void ConfigureStates(GameStateMachine stateMachine)
        {
            // Base states must be initialized first.
            base.ConfigureStates(stateMachine);

            // Substates of StatePlay.
            stateBeginPlay = new StateBeginPlay();
            stateBeginPlay.Configure(stateMachine);

            stateEvaluate = new StateEvaluate();
            stateEvaluate.Configure(stateMachine);
        }
Пример #8
0
    public void EnterNewState(BaseState newState)
    {
        if (CurrentState != null)
        {
            CurrentState.Sleep();
        }

        _statesStack.Push(newState);

        if (CurrentState != null)
        {
            CurrentState.EnterState();
        }
    }
Пример #9
0
    public static string Serialize(BaseState data)
    {
        var blocks = data.blockStates;
        var bData = blocks.Select(b => new List<float>() {
          (float)b.blockType,
          b.x,
          b.y,
          b.z,
          b.qx,
          b.qy,
          b.qz,
          b.qw,
        }).ToList();

        return MiniJSON.Json.Serialize(bData);
    }
Пример #10
0
        /// <summary>
        /// Configure all the game states.
        /// </summary>
        /// <param name="stateMachine">The game state machine.</param>
        public virtual void ConfigureStates(GameStateMachine stateMachine)
        {
            this.stateMachine = stateMachine;

            stateConfiguration = new StateConfiguration();
            stateIdle = new StateIdle();
            statePlay = new StatePlay();
            statePayWin = new StatePayWin();
            stateGameOver = new StateGameOver();

            stateConfiguration.Configure(stateMachine);
            stateIdle.Configure(stateMachine);
            statePlay.Configure(stateMachine);
            statePayWin.Configure(stateMachine);
            stateGameOver.Configure(stateMachine);
        }
Пример #11
0
 //TODO after each of these item effect
 private void FireTwinRocket_OnEnter(On.EntityStates.Drone.DroneWeapon.FireTwinRocket.orig_OnEnter orig, BaseState self)
 {
     orig(self);
     //if(self.outer.commonComponents.characterBody.inventory.GetItemCount())
     checkMissile(self);
 }
Пример #12
0
 //State Transitions
 public override IEnumerator EnterState(BaseState prevState)
 {
     CheckGround();
     yield return(base.EnterState(prevState));
 }
Пример #13
0
    public void SaveBaseState(string name, BaseState state)
    {
        // TODO: Make user base state into a single entry (the serializing/deserializing is a bigger overhead than the size)

        // Serialize to a string
        var dataText = Serialize(state);

        // Save string
        SaveData(name, dataText);

        // Add Data Name
        AddDataName(name);
    }
Пример #14
0
        public TcpClientPort(PortConfig portConfig, IPPortEndpointConfig ipPortEndpointConfig, string className)
            : base(portConfig, className)
        {
            targetEPConfig = ipPortEndpointConfig;

            PortBehavior = new PortBehaviorStorage() { DataDeliveryBehavior = DataDeliveryBehavior.ByteStream, IsNetworkPort = true, IsClientPort = true };

            PrivateBaseState = new BaseState(false, true);
            PublishBaseState("object constructed");
        }
Пример #15
0
    /// <summary>
    /// Start off in the Idle State.</summary>
    void Start()
    {
        _currentState = _idleState;
        CharacterStatsChanged();

        // Add to the static list of characters in the scene
        Character._allCharacters.Add(this);
    }
Пример #16
0
 public void SetState(BaseState baseState)
 {
     CurrentState = baseState;
 }
 public override void InitializeStates(out BaseState default_state)
 {
     default_state = root;
     root.ToggleAnims("anim_incapacitated_kanim", 0f).ToggleStatusItem(Db.Get().DuplicantStatusItems.Incapacitated, (StatesInstance smi) => smi.master.gameObject.GetSMI <IncapacitationMonitor.Instance>()).Enter(delegate(StatesInstance smi)
     {
         smi.SetStatus(Status.Failed);
         smi.GoTo(incapacitation_root.lookingForBed);
     });
     incapacitation_root.EventHandler(GameHashes.Died, delegate(StatesInstance smi)
     {
         smi.SetStatus(Status.Failed);
         smi.StopSM("died");
     });
     incapacitation_root.lookingForBed.Update("LookForAvailableClinic", delegate(StatesInstance smi, float dt)
     {
         smi.master.FindAvailableMedicalBed(smi.master.GetComponent <Navigator>());
     }, UpdateRate.SIM_1000ms, false).Enter("PlayAnim", delegate(StatesInstance smi)
     {
         smi.sm.clinic.Set(null, smi);
         smi.Play(IncapacitatedDuplicantAnim_pre, KAnim.PlayMode.Once);
         smi.Queue(IncapacitatedDuplicantAnim_loop, KAnim.PlayMode.Loop);
     });
     incapacitation_root.rescue.ToggleChore((StatesInstance smi) => new RescueIncapacitatedChore(smi.master, masterTarget.Get(smi)), incapacitation_root.recovering, incapacitation_root.lookingForBed);
     incapacitation_root.rescue.waitingForPickup.EventTransition(GameHashes.OnStore, incapacitation_root.rescue.carried, null).Update("LookForAvailableClinic", delegate(StatesInstance smi, float dt)
     {
         bool flag2 = false;
         if ((UnityEngine.Object)smi.sm.clinic.Get(smi) == (UnityEngine.Object)null)
         {
             flag2 = true;
         }
         else if (!smi.master.gameObject.GetComponent <Navigator>().CanReach(clinic.Get(smi).GetComponent <Clinic>()))
         {
             flag2 = true;
         }
         else if (!clinic.Get(smi).GetComponent <Assignable>().IsAssignedTo(smi.master.GetComponent <IAssignableIdentity>()))
         {
             flag2 = true;
         }
         if (flag2)
         {
             smi.GoTo(incapacitation_root.lookingForBed);
         }
     }, UpdateRate.SIM_1000ms, false);
     incapacitation_root.rescue.carried.Update("LookForAvailableClinic", delegate(StatesInstance smi, float dt)
     {
         bool flag = false;
         if ((UnityEngine.Object)smi.sm.clinic.Get(smi) == (UnityEngine.Object)null)
         {
             flag = true;
         }
         else if (!clinic.Get(smi).GetComponent <Assignable>().IsAssignedTo(smi.master.GetComponent <IAssignableIdentity>()))
         {
             flag = true;
         }
         if (flag)
         {
             smi.GoTo(incapacitation_root.lookingForBed);
         }
     }, UpdateRate.SIM_1000ms, false).Enter(delegate(StatesInstance smi)
     {
         smi.Queue(IncapacitatedDuplicantAnim_carry, KAnim.PlayMode.Loop);
     }).Exit(delegate(StatesInstance smi)
     {
         smi.Play(IncapacitatedDuplicantAnim_place, KAnim.PlayMode.Once);
     });
     incapacitation_root.death.PlayAnim(IncapacitatedDuplicantAnim_death).Enter(delegate(StatesInstance smi)
     {
         smi.SetStatus(Status.Failed);
         smi.StopSM("died");
     });
     incapacitation_root.recovering.ToggleUrge(Db.Get().Urges.HealCritical).Enter(delegate(StatesInstance smi)
     {
         smi.Trigger(-1256572400, null);
         smi.SetStatus(Status.Success);
         smi.StopSM("recovering");
     });
 }
Пример #18
0
 public void AddInterruptTransition(BaseTransition interruptTransition, BaseState nextState)
 {
     interruptTransition.SetNextState(nextState);
     m_interruptTransitions.Add(interruptTransition);
 }
Пример #19
0
 public void AddEndTransition(BaseTransition endTransition, BaseState nextState)
 {
     endTransition.SetNextState(nextState);
     m_endTransition = endTransition;
 }
Пример #20
0
 public override void InitializeStates(out BaseState default_state)
 {
     default_state = birthpre;
     root.ToggleStatusItem(MooReproductionStrings.CREATURES.STATUSITEMS.GIVINGBIRTH.
                           NAME, MooReproductionStrings.CREATURES.STATUSITEMS.GIVINGBIRTH.TOOLTIP, "",
                           StatusItem.IconType.Info, NotificationType.Neutral, false, default, 129022,
 public override void InitializeStates(out BaseState default_state)
 {
     default_state = root;
 }
Пример #22
0
    //  ////////////////////////////////////////////////     Main Actions...  ^ % $ # ! $ ^    Interrupted
    public virtual void Interrupted(BaseState pTempExitState)
    {
        mIsExitStateChanged = true;
        mDidExecute_Entry = false;
        pTempExitState.mDidExecute_Entry = false;
        mTempExitState = pTempExitState;  // [2012:10:11:MOON] Interrupt Twisting..
        string theMark = "=> => => "; //" ~ ~ ~ ";
        string theLine = theMark + theMark + theMark + theMark + theMark + theMark + theMark + theMark + theMark + theMark + theMark;
        theLine = theLine + theLine;

        //Ag.LogString (theLine);
        //Debug.Log( ); // Debug.Log( theLine + "\n");
        MarkSign();
        Debug.Log ("BaseState :: >>> Interrupted :: From [ " + mName + " ]  ==>>  To [ " + pTempExitState.mName + " ]  <<<< Interruped  >>>>\n");

        //Ag.LogString (theLine);
    }
Пример #23
0
 /// <summary>
 /// Change the State to the given state if the given state differs
 /// from the current state.</summary>
 public void ChangeState(BaseState state)
 {
     if (state != _currentState)
     {
         _currentState.ExitState();
         state._previousState = _currentState;
         _currentState = state;
         _currentState.EnterState();
         StateChanged(state);
     }
 }
Пример #24
0
    public BaseState CreateRain(string _clipname, AudioClip _clip, float multiplier = 8.0f)
    {
        multiplier = 8.0f;
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        double beattime = ba.GetBeatTime() * multiplier;

        Vector3 target = new Vector3(transform.position.x, -8, transform.position.z);

        BaseState.Attack torrent = () =>
        {
            Vector3 pos = gameObject.GetComponent <Transform>().position;
            pos.y    = 9;
            pos.x    = Random.Range(0, 16);
            target.x = pos.x;
            // rain left?
            target.x -= 8;

            Object o;
            o = Resources.Load("Prefabs/Projectile1");

            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            GameObject parent = Instantiate(Resources.Load("Prefabs/FakeParent") as GameObject);
            newgo.transform.parent = parent.transform;
            newgo.GetComponent <Projectile>().SetTarget(target);
            newgo.GetComponent <Projectile>().SetDir((target - pos).normalized);
            newgo.GetComponent <Projectile>().SetSpeed(7);

            // uhh, they dont destroy themselves, so i added this
            Destroy(parent, 3);
        };

        BaseState.Attack att = () =>
        {
            Vector3 pos = gameObject.GetComponent <Transform>().position;
            pos.y    = 9;
            pos.x    = Random.Range(-7, 8);
            target.x = pos.x;
            // rain left?
            target.x -= 8;

            Object o;
            o = Resources.Load("Prefabs/Projectile2");

            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            GameObject parent = Instantiate(Resources.Load("Prefabs/FakeParent") as GameObject);
            newgo.transform.parent = parent.transform;
            newgo.GetComponent <Projectile>().SetTarget(target);
            newgo.GetComponent <Projectile>().SetDir((target - pos).normalized);
            newgo.GetComponent <Projectile>().SetSpeed(7);

            // uhh, they dont destroy themselves, so i added this
            Destroy(parent, 3);
        };

        for (double time = 0; time < _clip.length; time += (beattime * 0.05f))
        {
            result.AddAttack(time, torrent);
            result.m_audioManager = ap;
        }

        for (double time = 0; time < _clip.length; time += beattime)
        {
            result.AddAttack(time, att);
            result.m_audioManager = ap;
        }

        m_StateMap[_clipname] = result;
        result.Sort();

        return(result);
    }
Пример #25
0
 void UpdateStateName(string updatedName, BaseState state)
 {
     if ( updatedName != state.name )
     {
         SerializedObject serializedObject = new SerializedObject(state);
         serializedObject.FindProperty("name").stringValue = updatedName;
         serializedObject.ApplyModifiedProperties();
     }
 }
Пример #26
0
    public BaseState CreateDropState(string _clipname, AudioClip _clip, float multiplier = 1f)
    {
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        double beattime = ba.GetBeatTime() * multiplier;//0.5357; // 0.588

        Vector3 leftlimit  = new Vector3(-0.75f, 1, 0);
        Vector3 rightlimit = new Vector3(0.75f, 1, 0);
        float   prevprev   = 0;
        float   prev       = 0.5f;
        float   mult       = -1;

        BaseState.Attack att = () =>
        {
            Vector3 pos = gameObject.GetComponent <Transform>().position;

            if (prevprev != 0 && (prev == leftlimit.x || prev == rightlimit.x))
            {
                mult = -mult;
            }


            for (float i = -0.25f; i < 0.5f; i += 0.25f)
            {
                Object o;
                if (i == 0)
                {
                    o = Resources.Load("Prefabs/Projectile2");
                }
                else
                {
                    o = Resources.Load("Prefabs/Projectile1");
                }

                if (o == null)
                {
                    Debug.Log("Load failed");
                }
                GameObject go = o as GameObject;
                if (go == null)
                {
                    Debug.Log("Loaded object isn't GameObject");
                }
                GameObject newgo = Instantiate(go, pos, Quaternion.identity);
                if (newgo == null)
                {
                    Debug.Log("Couldn't instantiate");
                }
                newgo.GetComponent <Projectile>().SetDir(new Vector3(prev + (i * mult), -1, 0));
                newgo.GetComponent <Projectile>().SetSpeed(10);
                if (i == 0.25)
                {
                    prevprev = prev;
                    prev     = prev + (i * mult);
                }
                Debug.Log(prev);
            }
        };

        for (double time = 0; time < _clip.length; time += beattime)
        {
            result.AddAttack(time, att);
            result.m_audioManager = ap;
        }

        m_StateMap[_clipname] = result;
        result.Sort();

        return(result);
    }
Пример #27
0
 public void TriggerState(BaseState state)
 {
     _triggerState(state);
 }
Пример #28
0
 protected virtual void OnCurrentStateChanged(BaseState oldValue, BaseState newValue)
 {
 }
Пример #29
0
 public override void InitializeStates(out BaseState defaultState)
 {
     defaultState = Off;
     Off.PlayAnim("misc").EventTransition(GameHashes.OperationalChanged, On, smi => smi.GetComponent <Operational>().IsOperational);
     On.Enter("SetActive", smi => smi.GetComponent <Operational>().SetActive(true, false)).PlayAnim("on").EventTransition(GameHashes.OperationalChanged, Off, smi => !smi.GetComponent <Operational>().IsOperational).ToggleStatusItem(Db.Get().BuildingStatusItems.EmittingLight, null);
 }
    //=================================================================================================================o
    //===============================================Combat============================================================o
    //=================================================================================================================o
    void _Combat()
    {
        // Combat Stance / Out
        if (doCombat && canDrawHolster)
        {
            // Coroutine draw motion finished -> switch
            if (weaponState == WeaponState.None)
            {
                return;
            }
            /*else if(weaponState == WeaponState.Unarmed)
            {
                return;
            }*/
            else if (weaponState == WeaponState.Sword)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.sword_Holster.GetComponent<Renderer>(), weapons.sword_Hand.GetComponent<Renderer>()));
                animator.SetBool("Sword", false);
                baseState = BaseState.Base;
            }
            else if (weaponState == WeaponState.Bow)
            {
                StartCoroutine(DrawHolster(0.6f, weapons.bow_Holster.GetComponent<Renderer>(), weapons.bow_Hand.GetComponent<Renderer>()));
                animator.SetBool("Bow", false);
                baseState = BaseState.Base;
            }
            else if (weaponState == WeaponState.Rifle)
            {
                StartCoroutine(DrawHolster(0.9f, weapons.rifle_Holster.GetComponent<Renderer>(), weapons.rifle_Hand.GetComponent<Renderer>()));
                animator.SetBool("Rifle", false);
                baseState = BaseState.Base;
            }
            else if (weaponState == WeaponState.Pistol)
            {
                StartCoroutine(DrawHolster(0.6f, weapons.pistol_Holster.GetComponent<Renderer>(), weapons.pistol_Hand.GetComponent<Renderer>()));
                animator.SetBool("Pistol", false);
                baseState = BaseState.Base;
            }
        }

        // Double Tap - Evade takes tapSpeed & coolDown in seconds
        if (canEvade)
        {
            if (!isDoubleTap) StartCoroutine(DoubleTap(doubleTapSpeed, 1));
        }

        // Current state info for layer Base
        animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);

        if (grounded)
        {
            if (doJumpDown /*&& canJump */&& !animatorStateInfo.IsTag("Jump") && !animatorStateInfo.IsTag("Land"))
            {
                animator.SetBool("Jump", true);
                //add extra force to main jump
                rigidbody.velocity = hero.up * jumpHeight;
                // Start cooldown until we can jump again
                //StartCoroutine (JumpCoolDown(0.5f));
            }

            // Don't slide
            if (!rigidbody.isKinematic)
                rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0);

            // Extra rotation
            if (canRotate)
            {
                if (!doLShift)
                    hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);
            }

            // Punch, Kick
            if (doAtk1Down && !animatorStateInfo.IsTag("Attack1"))
            {
                animator.SetBool("Attack1", true);
                animator.SetBool("Walking", false); // RESET
                animator.SetBool("Sprinting", false); // RESET
                animator.SetBool("Sneaking", false); // RESET
            }
            else if (doAtk2Down && !animatorStateInfo.IsTag("Attack2"))
            {

                animator.SetBool("Attack2", true);
                animator.SetBool("Walking", false); // RESET
                animator.SetBool("Sprinting", false); // RESET
                animator.SetBool("Sneaking", false); // RESET
            }

            // Walk
            if (doWalk)
            {
                if (!animatorStateInfo.IsTag("WalkTree"))//IsName("WalkTree.TreeW"))
                {
                    animator.SetBool("Walking", true);
                    animator.SetBool("Sneaking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Walking", false); // RESET
                }
            }

            // Sprint
            else if (doSprint)
            {
                if (!animatorStateInfo.IsTag("SprintTree"))
                {
                    animator.SetBool("Sprinting", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
                else
                {
                    animator.SetBool("Sprinting", false); // RESET
                }
            }

            // Sneak
            else if (doSneak)
            {
                if (!animatorStateInfo.IsTag("SneakTree"))
                {
                    animator.SetBool("Sneaking", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Sneaking", false); // RESET
                }
            }

            WallGround();

            // -----------AirTime--------- //
            if (!animator.GetBool("CanLand")) // Very short air time
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.4f)
                {
                    animator.SetBool("CanLand", true);
                }
            }
            else
                groundTime = 0;

            // -----------AirTime--------- //

        }
        else // In Air
        {
            // -----------AirTime--------- //
            if (groundTime <= 0.3f)
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.2f)
                {
                    animator.SetBool("CanLand", true);
                }
                else
                    animator.SetBool("CanLand", false);
            }
            // -----------AirTime--------- //

            if (canRotate)
                hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);

            WallRun();
        }

        // Resetting--------------------------------------------------
        if (!animator.IsInTransition(0))
        {
            if (animatorStateInfo.IsTag("Jump") || animatorStateInfo.IsTag("LedgeJump"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Jump", false); // RESET
            }

            if (animatorStateInfo.IsTag("Shoot") && !doAtk1)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }

            if ((animatorStateInfo.IsName("SwordCombo_L.slash1")
                || animatorStateInfo.IsName("SwordCombo_L.slash2")) && animatorStateInfo.normalizedTime > 0.4f && !doAtk1)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }
            else if (animatorStateInfo.IsName("SwordCombo_L.slash2.5"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }

            if ((animatorStateInfo.IsName("SwordCombo_R.slash3")
                || animatorStateInfo.IsName("SwordCombo_R.slash4")) && animatorStateInfo.normalizedTime > 0.4f && !doAtk2)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }
            else if (animatorStateInfo.IsName("SwordCombo_R.slash5"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }

            if (animatorStateInfo.IsTag("Evade"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Evade_F", false); // RESET
                animator.SetBool("Evade_B", false); // RESET
                animator.SetBool("Evade_L", false); // RESET
                animator.SetBool("Evade_R", false); // RESET
            }

            if (animatorStateInfo.IsTag("WallRun") && grounded) // No instant reset
            {
                animator.SetBool("WallRunL", false); // RESET
                animator.SetBool("WallRunR", false); // RESET
                animator.SetBool("WallRunUp", false); // RESET
            }
        }
    }
Пример #31
0
 public override IEnumerator ExitState(BaseState nextState)
 {
     yield return(base.ExitState(nextState));
 }
 //=================================================================================================================o
 // End ragdoll modus
 void EndRagdoll(int s)
 {
     rigidbody.isKinematic = false;
     int i;
     for (i = 0; i < bones.Length; i++)
     {
         if (bones[i] != hero.root && bones[i].GetComponent<Rigidbody>())
         {
             bones[i].GetComponent<Rigidbody>().isKinematic = true;
             bones[i].GetComponent<Collider>().isTrigger = true;
         }
     }
     animator.enabled = true;
     animator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
     animator.SetBool("StandUp", true);
     animator.SetInteger("RandomM", s);
     endRagdoll = false;
     baseState = BaseState.Base;
 }
Пример #33
0
    public BaseState CreateParryState(string _clipname, AudioClip _clip, float multiplier = 1f)
    {
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        double  beattime = ba.GetBeatTime() * multiplier;//0.5357; // 0.588
        Vector3 target   = new Vector3(-8, -2, transform.position.z);
        int     mult     = 1;
        int     prevprev = 0;

        BaseState.Attack spawnplatforms = () =>
        {
            for (int i = -2; i < 3; ++i)
            {
                gameObject.GetComponent <PlatformGenerator>().GeneratePlatform(new Vector3(i * 4, -8), new Vector3(i * 4, -6));
            }
        };
        result.AddAttack(0, spawnplatforms);
        result.AddAttack(0.2f, gameObject.GetComponent <PlatformGenerator>().ToggleGround);

        result.AddAttack(_clip.length - 0.01f, gameObject.GetComponent <PlatformGenerator>().DespawnAll);
        result.AddAttack(_clip.length - 0.02f, gameObject.GetComponent <PlatformGenerator>().ToggleGround);

        BaseState.Attack att = () =>
        {
            if (prevprev != 0 && Mathf.Abs(target.x) == 8)
            {
                mult = -mult;
            }
            Vector3 pos = gameObject.GetComponent <Transform>().position;
            Object  o   = Resources.Load("Prefabs/Projectile4");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            GameObject parent = Instantiate(Resources.Load("Prefabs/FakeParent") as GameObject);
            newgo.transform.parent = parent.transform;
            newgo.GetComponent <Projectile>().SetTarget(target);
            newgo.GetComponent <Projectile>().SetDir((target - pos).normalized);
            newgo.GetComponent <ExplodingProjectile>().SetSplitCount(6);
            newgo.GetComponent <Projectile>().SetSpeed(5);
            prevprev  = (int)(target.x);
            target.x += (4 * mult);
        };

        for (double time = 0; time < _clip.length; time += beattime)
        {
            result.AddAttack(time, att);
            result.m_audioManager = ap;
        }

        result.AddAttack(_clip.length - 0.5f, GetComponent <PlatformGenerator>().DespawnAll);


        m_StateMap[_clipname] = result;
        result.Sort();

        return(result);
    }
Пример #34
0
 private void checkMissile(BaseState self)
 {
     throw new NotImplementedException();
 }
Пример #35
0
    // Quick Time Event
    public BaseState CreateQuickTimeEvent(string _clipname, AudioClip _clip, float multiplier = 1.0f)
    {
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        multiplier *= 2.5f;
        double beattime = ba.GetBeatTime() * multiplier;

        // 1 - Up
        // 2 - Right
        // 3 - Down
        // 4 - Left

        int    _counter       = 0;
        int    _buttonPressed = 0;
        double _QTETime       = 0.0;
        int    totalDmg       = 0;
        double fifthTime      = (beattime * 0.19);
        float  warnTime       = (float)(beattime * (0.2 * multiplier));
        int    _countdown     = 0;

        //Possible Keys
        List <int> _InputKeys = new List <int>();
        //List<bool> _outcomeKeys = new List<bool>();

        int numberofKeys = 30;

        for (int i = 0; i < numberofKeys; ++i)
        {
            // which f*****g idiot
            // thought it was a smart idea
            // to have min and max
            // have the min be "inclusive"
            // BUT THE MAX IS "EXCLUSIVE"
            // WHY?
            // WHY ARE YOU LIKE THIS?
            _InputKeys.Add(Random.Range(1, 5));
        }

        GameObject        _buttonQTE;
        List <GameObject> _buttonList = new List <GameObject>();

        GameObject _feedback = GameObject.FindGameObjectWithTag("Feedback");

        BaseState.Attack warn = () =>
        {
            ++_countdown;

            switch (_countdown)
            {
            case 1:
                _feedback.GetComponent <Feedback>().CreateImage("CountReady", new Vector3(0, 0), warnTime);
                break;

            case 2:
                _feedback.GetComponent <Feedback>().CreateImage("CountThree", new Vector3(0, 0), warnTime);
                break;

            case 3:
                _feedback.GetComponent <Feedback>().CreateImage("CountTwo", new Vector3(0, 0), warnTime);
                break;

            case 4:
                _feedback.GetComponent <Feedback>().CreateImage("CountOne", new Vector3(0, 0), warnTime);
                break;

            case 5:
                _feedback.GetComponent <Feedback>().CreateImage("CountGo", new Vector3(0, 0), warnTime);
                break;
            }
        };

#if UNITY_STANDALONE || UNITY_WEBPLAYER
        BaseState.Attack att = () =>
        {
            if (_counter >= numberofKeys)
            {
                print("done");

                return;
            }

            if (_QTETime == 0.0)
            {
                if (_InputKeys[_counter] == 1)
                {
                    _buttonQTE = Instantiate(Resources.Load("Prefabs/KeyboardQ") as GameObject);
                    _buttonQTE.transform.parent = pc.transform;

                    Vector3 _buttonPos = pc.transform.position;
                    Vector2 _randPos   = Random.insideUnitCircle;
                    _buttonPos   += new Vector3(_randPos.x, _randPos.y);
                    _buttonPos.y += 2;
                    _buttonQTE.transform.position = _buttonPos;

                    _buttonList.Add(_buttonQTE);

                    //Destroy(_buttonQTE, (float)beattime);
                }
                if (_InputKeys[_counter] == 2)
                {
                    _buttonQTE = Instantiate(Resources.Load("Prefabs/KeyboardW") as GameObject);
                    _buttonQTE.transform.parent = pc.transform;

                    Vector3 _buttonPos = pc.transform.position;
                    Vector2 _randPos   = Random.insideUnitCircle;
                    _buttonPos   += new Vector3(_randPos.x, _randPos.y);
                    _buttonPos.y += 2;
                    _buttonQTE.transform.position = _buttonPos;

                    _buttonList.Add(_buttonQTE);

                    //Destroy(_buttonQTE, (float)beattime);
                }
                if (_InputKeys[_counter] == 3)
                {
                    _buttonQTE = Instantiate(Resources.Load("Prefabs/KeyboardE") as GameObject);
                    _buttonQTE.transform.parent = pc.transform;

                    Vector3 _buttonPos = pc.transform.position;
                    Vector2 _randPos   = Random.insideUnitCircle;
                    _buttonPos   += new Vector3(_randPos.x, _randPos.y);
                    _buttonPos.y += 2;
                    _buttonQTE.transform.position = _buttonPos;

                    _buttonList.Add(_buttonQTE);

                    //Destroy(_buttonQTE, (float)beattime);
                }
                if (_InputKeys[_counter] == 4)
                {
                    _buttonQTE = Instantiate(Resources.Load("Prefabs/KeyboardR") as GameObject);
                    _buttonQTE.transform.parent = pc.transform;

                    Vector3 _buttonPos = pc.transform.position;
                    Vector2 _randPos   = Random.insideUnitCircle;
                    _buttonPos   += new Vector3(_randPos.x, _randPos.y);
                    _buttonPos.y += 2;
                    _buttonQTE.transform.position = _buttonPos;

                    _buttonList.Add(_buttonQTE);

                    //Destroy(_buttonQTE, (float)beattime);
                }
            }

            _buttonPressed = 0;
            _QTETime      += Time.deltaTime * 8;

            for (int i = 1; i < 5; ++i)
            {
                if (pc._keys[i] > 0.0)
                {
                    // will this even.. get called, at all? wtf.
                    // If newer key is pressed, OVERRIDE
                    if (_buttonPressed != 0 && pc._keys[_buttonPressed] > pc._keys[i])
                    {
                        continue;
                    }

                    _buttonPressed = i;
                }
            }

            for (int i = 1; i < 5; ++i)
            {
                pc._keys[i] = -1.0;
            }

            if (_buttonPressed == _InputKeys[_counter])
            {
                //succ ess full
                print("QTE SUCCESS");

                // spawn a tick above player head
                // con-fookin-gratis
                // you pressed a button
                _feedback.GetComponent <Feedback>().CreateImage("ParryPass", pc.transform.position + new Vector3(0, 1));
                _feedback.GetComponent <Feedback>().CreateAudio("Pass");

                _QTETime = 0.0;
                Destroy(_buttonList[0]);
                _buttonList.Remove(_buttonList[0]);

                //_outcomeKeys.Add(true);
                ++totalDmg;
                ++_counter;

                // Add base 100 score
                playerScore.AddScore(100.0f);
            }
            else
            {
                // If they do the same shit, why not merge them?
                // Because what if we do different things :worry:

                // Press wrong
                if (_buttonPressed != 0)
                {
                    // boi you fuked up
                    // oof ooch owie
                    print("Wrong Button!");

                    // how are you so bad
                    _feedback.GetComponent <Feedback>().CreateImage("ParryFail", pc.transform.position + new Vector3(0, 1));
                    _feedback.GetComponent <Feedback>().CreateAudio("Fail");

                    _QTETime = 0.0;
                    Destroy(_buttonList[0]);
                    _buttonList.Remove(_buttonList[0]);

                    pc.screenShake.ShakeCamera();
                    //_outcomeKeys.Add(false);
                    ++_counter;
                } // Out of time
                else if (_QTETime > beattime)
                {
                    // boi you fuked up
                    // oof ooch owie
                    print("Too slow!");

                    // how are you so bad
                    _feedback.GetComponent <Feedback>().CreateImage("ParryFail", pc.transform.position + new Vector3(0, 1));
                    _feedback.GetComponent <Feedback>().CreateAudio("Fail");

                    _QTETime = 0.0;
                    Destroy(_buttonList[0]);
                    _buttonList.Remove(_buttonList[0]);

                    pc.screenShake.ShakeCamera();
                    //_outcomeKeys.Add(false);
                    ++_counter;
                }
            }
        };
#elif UNITY_ANDROID || UNITY_EDITOR
        BaseState.Attack att = () =>
        {
            if (_counter >= numberofKeys)
            {
                print("done");

                return;
            }

            if (_QTETime == 0.0)
            {
                _buttonQTE = Instantiate(Resources.Load("Prefabs/QTETappable") as GameObject);
                _buttonQTE.transform.SetParent(GameObject.FindGameObjectWithTag("MobileCanvas").transform);
                Vector2 _randPos = Random.insideUnitCircle;
                _buttonQTE.transform.localPosition = new Vector3((_randPos.x * 250.0f), (_randPos.y * 150.0f)); // 400 is 0, 250 is 0
                _buttonList.Add(_buttonQTE);
            }

            // ever wondered why you have no time to qte?
            _QTETime += Time.deltaTime * 8;

            if (QTETappable._tapped)
            {
                //succ ess full
                print("QTE SUCCESS");

                // spawn a tick above player head
                // con-fookin-gratis
                // you pressed a button
                _feedback.GetComponent <Feedback>().CreateImage("ParryPass", pc.transform.position + new Vector3(0, 1));
                _feedback.GetComponent <Feedback>().CreateAudio("Pass");

                _QTETime = 0.0;
                Destroy(_buttonList[0]);
                _buttonList.Remove(_buttonList[0]);

                //_outcomeKeys.Add(true);
                ++totalDmg;
                ++_counter;

                // Add base 100 score
                playerScore.AddScore(100.0f);

                QTETappable._tapped = false;
            }

            if (_QTETime > beattime)
            {
                // boi you fuked up
                // oof ooch owie
                print("Too slow!");

                // how are you so bad
                _feedback.GetComponent <Feedback>().CreateImage("ParryFail", pc.transform.position + new Vector3(0, 1));
                _feedback.GetComponent <Feedback>().CreateAudio("Fail");

                _QTETime = 0.0;
                Destroy(_buttonList[0]);
                _buttonList.Remove(_buttonList[0]);

                pc.screenShake.ShakeCamera();
                //_outcomeKeys.Add(false);
                ++_counter;

                QTETappable._tapped = false;
            }
        };
#endif

        BaseState.Attack clear = () =>
        {
            while (_buttonList.Count != 0)
            {
                Destroy(_buttonList[0]);
                _buttonList.Remove(_buttonList[0]);
            }

            // Add base 250 per successful parry
            playerScore.AddScore(250.0f * totalDmg);
            // Minus boss HP by totalDmg (or something)
            _bossHP.health -= totalDmg;
        };

        for (double time = 0; time < (beattime * 4); time += (double)warnTime)
        {
            result.AddAttack(time, warn);
            result.m_audioManager = ap;
        }

        for (double time = (beattime * 4); time < (_clip.length - 0.2f); time += beattime)
        {
            result.AddAttack(time, att);
            result.m_audioManager = ap;
        }

        result.AddAttack((_clip.length - 0.2f), clear);

        m_StateMap[_clipname] = result;
        result.Sort();

        return(result);
    }
Пример #36
0
    // Shockwave Projectile (Drop 2 or some shit?)
    public BaseState CreateShockwaveProjectile(string _clipname, AudioClip _clip, float multiplier = 8.0f)
    {
        multiplier = 8.0f;
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        double beattime = ba.GetBeatTime() * multiplier;

        //            Vector3 pos = new Vector3(Random.Range(-7, 8), 8);
        //target.x = pos.x;
        //gameObject.GetComponent<Transform>().position.Set(Random.Range(-7, 8), gameObject.GetComponent<Transform>().position.y, gameObject.GetComponent<Transform>().position.z);
        Vector3 target = new Vector3(transform.position.x, -4, transform.position.z);

        // uhh how do i slow down spawning omegalul

        BaseState.Attack att = () =>
        {
            Vector3 pos = gameObject.GetComponent <Transform>().position;
            pos.y    = 9;
            pos.x    = Random.Range(-7, 8);
            target.x = pos.x;

            Object o = Resources.Load("Prefabs/ProjectileShockwave");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }
            ;

            GameObject parent = Instantiate(Resources.Load("Prefabs/FakeParent") as GameObject);
            newgo.transform.parent = parent.transform;
            newgo.GetComponent <Projectile>().SetTarget(target);
            newgo.GetComponent <Projectile>().SetDir((target - pos).normalized);
            newgo.GetComponent <ShockwaveProjectile>().SetWaves(5);
            newgo.GetComponent <Projectile>().SetSpeed(10);
            newgo.GetComponent <Projectile>().transform.localScale *= 2;
        };

        for (double time = 0; time < _clip.length; time += beattime)
        {
            result.AddAttack(time, att);
            result.m_audioManager = ap;
        }

        m_StateMap[_clipname] = result;
        result.Sort();

        return(result);
    }
    //=================================================================================================================o
    //================================================Base=============================================================o
    //=================================================================================================================o
    void _Base()
    {
        // Next Weapon
        if (doNextWeapon && canNextWeapon)
        {
            StartCoroutine(NextWeapon());
        }

        // Combat Stance / Out
        else if (doCombat && canDrawHolster)
        {
            // Coroutine draw motion finished -> switch
            if (weaponState == WeaponState.None)
            {
                return;
            }
            /*else if(weaponState == WeaponState.Unarmed)
            {
                return;
            }*/
            else if (weaponState == WeaponState.Sword)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.sword_Hand.GetComponent<Renderer>(), weapons.sword_Holster.GetComponent<Renderer>()));
                animator.SetBool("Sword", true);
                baseState = BaseState.Combat;
            }
            else if (weaponState == WeaponState.Bow)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.bow_Hand.GetComponent<Renderer>(), weapons.bow_Holster.GetComponent<Renderer>()));
                animator.SetBool("Bow", true);
                baseState = BaseState.Combat;
            }
            else if (weaponState == WeaponState.Rifle)
            {
                StartCoroutine(DrawHolster(0.3f, weapons.rifle_Hand.GetComponent<Renderer>(), weapons.rifle_Holster.GetComponent<Renderer>()));
                animator.SetBool("Rifle", true);
                baseState = BaseState.Combat;
            }
            else if (weaponState == WeaponState.Pistol)
            {
                StartCoroutine(DrawHolster(0.2f, weapons.pistol_Hand.GetComponent<Renderer>(), weapons.pistol_Holster.GetComponent<Renderer>()));
                animator.SetBool("Pistol", true);
                baseState = BaseState.Combat;
            }
        }

        // Dance
        else if (doDance1)
        {
            animator.SetBool("Dance", true);
            animator.SetInteger("RandomM", 1);
        }
        else if (doDance2)
        {
            animator.SetBool("Dance", true);
            animator.SetInteger("RandomM", 2);
        }
        else if (doDance3)
        {
            animator.SetBool("Dance", true);
            animator.SetInteger("RandomM", 3);
        }

        // Pull Push
        else if (doPullLever)
        {
            animator.SetBool("Pull", true);
        }
        else if (doPushButton)
        {
            animator.SetBool("Push", true);
        }

        // Throw
        else if (doThrow)
        {
            animator.SetBool("Throw", true);
        }

        // Fly
        else if (doFly)
        {
            if (!canFly)
                return;
            rigidbody.useGravity = false;
            animator.SetBool("Jump", true);
            rigidbody.velocity = Vector3.up * 5; // Up in fast

            // Fly State
            if (animCtrl.fly)
            {
                animator.runtimeAnimatorController = animCtrl.fly;
                StartCoroutine(JustHolster());
                baseState = BaseState.Fly;
            }
        }

        // Climb
        else if (doClimb)
        {
            if (!canClimb)
                return;
            CheckClimb();

            if (climbState != ClimbState.None)
            {
                // Climb State
                if (animCtrl.climb)
                {
                    animator.runtimeAnimatorController = animCtrl.climb;
                    StartCoroutine(JustHolster());
                    baseState = BaseState.Climb; // Out
                }
            }
        }

        // Double Tap - Evade takes tapSpeed & coolDown in seconds
        if (canEvade)
        {
            if (!isDoubleTap) StartCoroutine(DoubleTap(doubleTapSpeed, 1));
        }

        // Start Radoll modus
        if (canRagdoll)
        {
            // When falling for time
            if (animatorStateInfo.IsTag("Fall") && animator.enabled)
            {
                float nTime = animatorStateInfo.normalizedTime;

                if (nTime > startRagTime && !animator.IsInTransition(0))
                {
                    StartRagdoll();
                }
            }
            else if (startRagdoll) // Manual switch
            {
                StartRagdoll();
            }
        }

        // Current state info for layer Base
        animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);

        if (grounded)
        {
            if (doJumpDown && canJump && !animatorStateInfo.IsTag("Jump") && !animatorStateInfo.IsTag("Land"))
            {
                animator.SetBool("Jump", true);
                //add extra force to main jump
                if (!animatorStateInfo.IsTag("LedgeJump"))
                    rigidbody.velocity = hero.up * jumpHeight;
                // Start cooldown until we can jump again
                //StartCoroutine (JumpCoolDown(0.5f));
            }

            // Don't slide
            if (!rigidbody.isKinematic)
                rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0);

            // Extra rotation
            if (canRotate)
            {
                if (!doLShift)
                    hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);
            }

            // Punch, Kick if weapon state is not = None
            if (weaponState != WeaponState.None)
            {
                if (doAtk1Down && !animatorStateInfo.IsName("PunchCombo.Punch1"))
                {
                    animator.SetBool("Attack1", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
                else if (doAtk2Down && !animatorStateInfo.IsName("KickCombo.Kick1"))
                {
                    animator.SetBool("Attack2", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
            }

            // Walk
            if (doWalk)
            {
                if (!animatorStateInfo.IsName("WalkTree.TreeW"))
                {
                    animator.SetBool("Walking", true);
                    animator.SetBool("Sneaking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Walking", false); // RESET
                }
            }

            // Sprint
            else if (doSprint)
            {
                if (!animatorStateInfo.IsName("SprintTree.TreeS"))
                {
                    animator.SetBool("Sprinting", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sneaking", false); // RESET
                }
                else
                {
                    animator.SetBool("Sprinting", false); // RESET
                }
            }

            // Sneak
            else if (doSneak)
            {
                if (!animatorStateInfo.IsName("SneakTree.TreeSn"))
                {
                    animator.SetBool("Sneaking", true);
                    animator.SetBool("Walking", false); // RESET
                    animator.SetBool("Sprinting", false); // RESET
                }
                else
                {
                    animator.SetBool("Sneaking", false); // RESET
                }
            }

            WallGround();

            // Balanceing trigger
            if (groundHit.transform && groundHit.transform.gameObject.layer == 9)
            {
                // Layer 9 should be Climb
                animator.SetBool("Balancing", true);
            }
            else
                animator.SetBool("Balancing", false); // RESET

            // -----------AirTime--------- //
            if (!animator.GetBool("CanLand")) // Very short air time
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.4f)
                {
                    animator.SetBool("CanLand", true);
                }
            }
            else
                groundTime = 0;

            // -----------AirTime--------- //

        }
        else // In Air
        {
            // -----------AirTime--------- //
            if (groundTime <= 0.3f)
            {
                groundTime += Time.deltaTime;
                if (groundTime >= 0.2f)
                {
                    animator.SetBool("CanLand", true);
                }
                else
                    animator.SetBool("CanLand", false);
            }
            // -----------AirTime--------- //

            if (canRotate)
                hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);

            WallRun();

            // After jumping off from climb state controller
            if (jumpOffNext)
            {
                animator.SetBool("Jump", true);
                jumpOffNext = false;
            }
        }

        // Resetting--------------------------------------------------
        if (!animator.IsInTransition(0))
        {
            if (animatorStateInfo.IsTag("Jump") || animatorStateInfo.IsTag("LedgeJump"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Jump", false); // RESET LedgeJump
            }

            else if (animatorStateInfo.IsTag("Dance"))
            {
                animator.SetBool("Dance", false);
            }

            else if (animatorStateInfo.IsTag("Action"))
            {
                animator.SetBool("Pull", false);
                animator.SetBool("Push", false);
                animator.SetBool("Throw", false);
            }

            else if (animatorStateInfo.IsTag("StandUp"))
            {
                animator.SetInteger("RandomM", 3); // 0 or 1 are triggers
                animator.SetBool("StandUp", false); // RESET
            }

            if (animatorStateInfo.IsName("PunchCombo.Punch1") && animatorStateInfo.normalizedTime > 0.7f && !doAtk1)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }
            else if (animatorStateInfo.IsName("PunchCombo.Punch2"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack1", false); // RESET
            }

            if (animatorStateInfo.IsName("KickCombo.Kick1") && animatorStateInfo.normalizedTime > 0.7f && !doAtk2)
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }
            else if (animatorStateInfo.IsName("KickCombo.Kick2"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Attack2", false); // RESET
            }

            if (animatorStateInfo.IsTag("Evade"))
            {
                // Reset our parameter to avoid looping
                animator.SetBool("Evade_F", false); // RESET
                animator.SetBool("Evade_B", false); // RESET
                animator.SetBool("Evade_L", false); // RESET
                animator.SetBool("Evade_R", false); // RESET
            }

            if (animatorStateInfo.IsTag("WallRun") && grounded) // No instant reset
            {
                animator.SetBool("WallRunL", false); // RESET
                animator.SetBool("WallRunR", false); // RESET
                animator.SetBool("WallRunUp", false); // RESET
            }
        }
    }
Пример #38
0
    public BaseState CreateLaserAttack(string _clipname, AudioClip _clip, float multiplier = 1f)
    {
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here
        double  beattime  = ba.GetBeatTime() * multiplier;
        Vector3 target    = new Vector3(-8.5f, transform.position.y, transform.position.z);
        Vector3 target2   = new Vector3(-12f, transform.position.y, transform.position.z);
        float   lifetime  = 2.0f;
        bool    alternate = false;

        BaseState.Attack warn = () =>
        {
            target.y  = Random.Range(-4, 2f);
            target2.y = target.y;

            Object o = Resources.Load("Prefabs/Indicator");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, target, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }
            Debug.Log(alternate);
            Destroy(newgo, lifetime);
        };


        BaseState.Attack att = () =>
        {
            Object o = Resources.Load("Prefabs/laserprojectile");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, target2, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo.GetComponent <Projectile>().SetDir(new Vector3(1, 0, 0));
            newgo.GetComponent <Projectile>().SetSpeed(15);
        };
        for (double time = 0; time < _clip.length; time += beattime)
        {
            if (alternate)
            {
                result.AddAttack(time, att);
            }
            else
            {
                result.AddAttack(time, warn);
            }

            alternate = !alternate;
            //result.AddAttack(time, att);
            result.m_audioManager = ap;
        }
        m_StateMap[_clipname] = result;
        result.Sort();

        return(result);
    }
    //=================================================================================================================o
    //================================================Fly==============================================================o
    //=================================================================================================================o
    void _Fly()
    {
        rigidbody.drag = flyDrag;

        // Rotation, if mouse movement
        if (mX != 0.0f)
        {
            hero.Rotate(0, mX * Time.fixedDeltaTime * diveRotSpeed * 55, 0, Space.Self);
        }
        // Leave Flying
        if (doFly)
        {
            rigidbody.useGravity = true;

            // Base State
            if (animCtrl.baseC)
            {
                rigidbody.drag = baseDrag;
                animator.runtimeAnimatorController = animCtrl.baseC;
                baseState = BaseState.Base; // Out
            }
        }

        // If input
        if (h != 0.0f || v != 0.0f)
        {
            // Movement Vector
            Vector3 flyVec = hero.right * h
                + cam.transform.forward * v;

            // Lift if grounded
            if (grounded)
            {
                groundTime += Time.deltaTime;

                if (groundTime > 0.6f)
                {
                    rigidbody.velocity = Vector3.Lerp(Vector3.zero, Vector3.up * 22, groundTime);
                    groundTime = 0;
                }
            }
            else
            {
                rigidbody.velocity = flyVec.normalized * flySpeed;
            }
        }
    }
Пример #40
0
    public BaseState CreateBlindAttack(string _clipname, AudioClip _clip, float multiplier = 1f)
    {
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        double beattime = ba.GetBeatTime() * multiplier;
        //for blackness
        Vector3 target = new Vector3(transform.position.x, 1.3f, transform.position.z);
        //for the projectile
        Vector3 target2 = new Vector3(transform.position.x, 10, transform.position.z);
        Vector3 target3 = new Vector3(transform.position.x, 10, transform.position.z);
        Vector3 target4 = new Vector3(transform.position.x, 10, transform.position.z);
        Vector3 target5 = new Vector3(transform.position.x, 10, transform.position.z);

        target.x = 0;
        target.z = -5;

        // uhh how do i slow down spawning omegalul

        float randomspeed;

        BaseState.Attack att = () =>
        {
            randomspeed = Random.Range(5, 10);
            target2.x   = Random.Range(-8, 8);
            target3.x   = Random.Range(-8, 8);
            target4.x   = Random.Range(-8, 8);
            target5.x   = Random.Range(-8, 8);

            Object o4 = Resources.Load("Prefabs/Black");
            if (o4 == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go4 = o4 as GameObject;
            if (go4 == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo4 = Instantiate(go4, target, Quaternion.identity);
            if (newgo4 == null)
            {
                Debug.Log("Couldn't instantiate");
            }
            Destroy(newgo4, 1);

            Object o = Resources.Load("Prefabs/Projectile2");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, target2, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo.GetComponent <Projectile>().SetDir(new Vector3(0, -1, 0));
            newgo.GetComponent <Projectile>().SetSpeed(randomspeed);

            Object o1 = Resources.Load("Prefabs/Projectile2");
            if (o1 == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go1 = o1 as GameObject;
            if (go1 == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo1 = Instantiate(go, target3, Quaternion.identity);
            if (newgo1 == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo1.GetComponent <Projectile>().SetDir(new Vector3(0, -1, 0));
            newgo1.GetComponent <Projectile>().SetSpeed(randomspeed);

            Object o2 = Resources.Load("Prefabs/Projectile2");
            if (o2 == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go2 = o2 as GameObject;
            if (go2 == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo2 = Instantiate(go, target4, Quaternion.identity);
            if (newgo2 == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo2.GetComponent <Projectile>().SetDir(new Vector3(0, -1, 0));
            newgo2.GetComponent <Projectile>().SetSpeed(randomspeed);

            Object o3 = Resources.Load("Prefabs/Projectile2");
            if (o3 == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go3 = o3 as GameObject;
            if (go3 == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo3 = Instantiate(go, target5, Quaternion.identity);
            if (newgo3 == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo3.GetComponent <Projectile>().SetDir(new Vector3(0, -1, 0));
            newgo3.GetComponent <Projectile>().SetSpeed(randomspeed);
        };

        for (double time = 0; time < _clip.length; time += beattime)
        {
            result.AddAttack(time, att);
        }

        result.m_audioManager = ap;

        m_StateMap[_clipname] = result;
        result.Sort();

        return(result);
    }
    //=================================================================================================================o
    void ExitClimb()
    {
        // Base State
        if (animCtrl.climb)
        {
            rigidbody.isKinematic = false;

            isTop = false; // RESET
            isOverhang = false; // RESET
            hero.rotation = Quaternion.Euler(0, curT.eulerAngles.y, 0);
            curT = null;
            climbState = ClimbState.None;
            animator.runtimeAnimatorController = animCtrl.baseC;
            baseState = BaseState.Base;
            reset = true; // Out
        }
    }
Пример #42
0
    public BaseState CreateBaseState(string _clipname, AudioClip _clip, float multiplier = 1f)
    {
        BaseState result = gameObject.AddComponent <BaseState>();

        result.SetClipName(_clip.name);
        //Run adding attacks here

        // ba.FindBpm();

        double beattime = ba.GetBeatTime() * multiplier;//0.5357; // 0.588 //ba.GetBeatTime()

        BaseState.Attack att = () =>
        {
            Vector3 pos    = gameObject.GetComponent <Transform>().position;
            Vector3 target = new Vector3(-1, -1, 0);
            Object  o      = Resources.Load("Prefabs/Projectile1");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo.GetComponent <Projectile>().SetDir(target);
            newgo.GetComponent <Projectile>().SetSpeed(10 / multiplier);


            for (int i = 0; i < 4; ++i)
            {
                GameObject newergo = Instantiate(newgo, pos, Quaternion.identity);
                target.x += 0.5f;

                newergo.GetComponent <Projectile>().SetDir(target);
                newergo.GetComponent <Projectile>().SetSpeed(10 / multiplier);
            }
        };

        BaseState.Attack att2 = () =>
        {
            Vector3 pos    = gameObject.GetComponent <Transform>().position;
            Vector3 target = new Vector3(-0.75f, -1, 0);
            Object  o      = Resources.Load("Prefabs/Projectile1");
            if (o == null)
            {
                Debug.Log("Load failed");
            }
            GameObject go = o as GameObject;
            if (go == null)
            {
                Debug.Log("Loaded object isn't GameObject");
            }
            GameObject newgo = Instantiate(go, pos, Quaternion.identity);
            if (newgo == null)
            {
                Debug.Log("Couldn't instantiate");
            }

            newgo.GetComponent <Projectile>().SetDir(target);
            newgo.GetComponent <Projectile>().SetSpeed(10 / multiplier);

            for (int i = 0; i < 3; ++i)
            {
                GameObject newergo = Instantiate(newgo, pos, Quaternion.identity);
                target.x += 0.5f;

                newergo.GetComponent <Projectile>().SetDir(target);
                newergo.GetComponent <Projectile>().SetSpeed(10 / multiplier);
            }
        };

        //int beatcount = 0;
        for (double time = 0; time < _clip.length; time += beattime)
        {
            result.AddAttack(time, att);
            result.AddAttack(time + beattime / 2, att2);

            result.m_audioManager = ap;
        }

        m_StateMap[_clipname] = result;
        result.Sort();
        return(result);
    }
Пример #43
0
        public ComPort(PortConfig portConfig, ComPortConfig comPortConfig)
            : base(portConfig, "ComPort")
        {
            this.comPortConfig = comPortConfig;
            PortBehavior = new PortBehaviorStorage() { DataDeliveryBehavior = DataDeliveryBehavior.ByteStream, IsClientPort = true };

            PrivateBaseState = new BaseState(false, true);
            PublishBaseState("object constructed");

            CreatePort();
        }
Пример #44
0
            public override void InitializeStates(out BaseState defaultState)
            {
                defaultState = NotOperational;

                root
                .EventTransition(GameHashes.OperationalChanged, NotOperational, smi => !smi.IsOperational);

                NotOperational
                .QueueAnim("off")
                .EventTransition(GameHashes.OperationalChanged, NoLight, smi => smi.IsOperational);

                NoLight
                .QueueAnim("off")
                .Enter(smi => smi.master.operational.SetActive(false))
                .Update("NoLight", (smi, dt) => { if (smi.HasLight() && smi.HasEnoughMass(GameTags.Fertilizer))
                                                  {
                                                      smi.GoTo(GotFert);
                                                  }
                        }, UpdateRate.SIM_1000ms);

                GotFert
                .PlayAnim("on_pre")
                .OnAnimQueueComplete(NoWater);

                LostFert
                .PlayAnim("on_pst")
                .OnAnimQueueComplete(NoFert);

                NoFert
                .QueueAnim("off")
                .EventTransition(GameHashes.OnStorageChange, GotFert, smi => smi.HasEnoughMass(GameTags.Fertilizer))
                .Enter(smi => smi.master.operational.SetActive(false));

                NoWater
                .QueueAnim("on")
                .Enter(smi => smi.master.GetComponent <PassiveElementConsumer>().EnableConsumption(true))
                .EventTransition(GameHashes.OnStorageChange, LostFert, smi => !smi.HasEnoughMass(GameTags.Fertilizer))
                .EventTransition(GameHashes.OnStorageChange, GotWater, smi => smi.HasEnoughMass(GameTags.Fertilizer) && smi.HasEnoughMass(GameTags.Water));

                GotWater
                .PlayAnim("working_pre")
                .OnAnimQueueComplete(GeneratingOxygen);

                GeneratingOxygen
                .Enter(smi => smi.master.operational.SetActive(true))
                .Exit(smi => smi.master.operational.SetActive(false))
                .QueueAnim("working_loop", true)
                .EventTransition(GameHashes.OnStorageChange, StoppedGeneratingOxygen,
                                 smi => !smi.HasEnoughMass(GameTags.Water) || !smi.HasEnoughMass(GameTags.Fertilizer))
                .Update("GeneratingOxygen", (smi, dt) => { if (!smi.HasLight())
                                                           {
                                                               smi.GoTo(StoppedGeneratingOxygen);
                                                           }
                        }, UpdateRate.SIM_1000ms);

                StoppedGeneratingOxygen
                .PlayAnim("working_pst")
                .OnAnimQueueComplete(StoppedGeneratingOxygenTransition);

                StoppedGeneratingOxygenTransition
                .Update("StoppedGeneratingOxygenTransition", (smi, dt) => { if (!smi.HasLight())
                                                                            {
                                                                                smi.GoTo(NoLight);
                                                                            }
                        }, UpdateRate.SIM_200ms)
                .EventTransition(GameHashes.OnStorageChange, NoWater, smi => !smi.HasEnoughMass(GameTags.Water) && smi.HasLight())
                .EventTransition(GameHashes.OnStorageChange, LostFert, smi => !smi.HasEnoughMass(GameTags.Fertilizer) && smi.HasLight())
                .EventTransition(GameHashes.OnStorageChange, GotWater, smi => smi.HasEnoughMass(GameTags.Water) && smi.HasLight() &&
                                 smi.HasEnoughMass(GameTags.Fertilizer));
            }
Пример #45
0
 // Use this for initialization
 void Start()
 {
     sprite = GetComponent<UISprite>();
     state = new BaseState(this);
     baseParameter = new BaseParameter(sprite);
 }
Пример #46
0
 private void OnStateChanged(BaseState obj)
 {
     // throw new NotImplementedException();
 }
Пример #47
0
 /// <summary>
 /// Override to do something after changing to a different State.</summary>
 public virtual void StateChanged(BaseState state)
 {
 }
Пример #48
0
 public void AddState(T id, BaseState state)
 {
     _states.Add(id, state);
 }
Пример #49
0
 public virtual void SwapState(BaseState nextState)
 {
     parentFsm.SwapState(nextState);
 }
Пример #50
0
 public void SetState(BaseState newState)
 {
     _currentState?.OnExit();
     _currentState = newState;
     _currentState.OnEnter();
 }
Пример #51
0
 public static void InitQB()
 {
     SilkTest.Ntf.Agent.SetOption(Options.ApplicationReadyTimeout, 10000);
     SilkTest.Ntf.Agent.SetOption(Options.PlaybackMode, ReplayMode.Default);
     SilkTest.Ntf.Agent.SetOption(Options.SyncTimeout, 10000);
     SilkTest.Ntf.Agent.SetOption(Options.ObjectResolveTimeout, 5000);
     SilkTest.Ntf.Agent.SetOption(Options.TruelogScreenshotMode, TruelogScreenshotMode.Desktop);
     BaseState baseState = new BaseState();
     baseState.CommandLineArguments = "/Fsuperpro -TickCount=19225688";
     baseState.Executable = "%Program Files%\\Intuit\\QuickBooks Enterprise Solutions 15.0\\QBW32.exe";
     baseState.WorkingDirectory = "%Program Files%\\Intuit\\QuickBooks Enterprise Solutions 15.0";
     baseState.Locator = "/Window";
     baseState.Execute();
     Thread.Sleep(10000);
 }
Пример #52
0
 public override void InitializeStates(out BaseState default_state)
 {
     serializable  = true;
     default_state = alive;
     alive.DoNothing();
 }
Пример #53
0
        private void LoginRequired(BaseState newState)
        {
            lock (StateLock)
            {
                State = newState;
            }

            if (OnLoginRequired != null)
            {
                if (InvokeRequired)
                    CheckedInvoke(OnLoginRequired, new object[] { this });
                else
                    OnLoginRequired(this);
            }
            else
            {
                FireOnError(new InvalidOperationException("If AutoLogin is false, you must supply a OnLoginRequired event handler"));
            }
        }
Пример #54
0
 public virtual void RemoveStateNode(BaseState state)
 {
     m_stateNodes.Remove(state);
 }
Пример #55
0
    public BaseState GetGameBaseState(GameObject baseObject, float maxDistanceFromBase)
    {
        var blockStates = new List<BlockState>();

        // Get all blocks of that base
        foreach (Transform childTransform in baseObject.transform)
        {
            if (childTransform.gameObject.tag == "BaseMarker")
            {
                continue;
            }

            var bObj = childTransform.gameObject;

            // Skip blocks that are too far from the base
            if (bObj.transform.localPosition.magnitude > maxDistanceFromBase)
            {
                continue;
            }

            var bState = new BlockState();
            bState.blockType = BlockState.GetBlockType(bObj.name);
            bState.x = bObj.transform.localPosition.x;
            bState.y = bObj.transform.localPosition.y;
            bState.z = bObj.transform.localPosition.z;
            bState.qx = bObj.transform.localRotation.x;
            bState.qy = bObj.transform.localRotation.y;
            bState.qz = bObj.transform.localRotation.z;
            bState.qw = bObj.transform.localRotation.w;

            blockStates.Add(bState);
        }

        var baseState = new BaseState();
        baseState.blockStates = blockStates.ToArray();

        return baseState;
    }
 public void SetNextState(BaseState nextState)
 {
     m_nextState = nextState;
 }
Пример #57
0
    public void SetGameBaseState(GameObject[] blockPrefabs, GameObject baseObject, BaseState state, int layerNumber, float maxDistanceFromBase)
    {
        // Remove children blocks of base
        foreach (Transform cTransform in baseObject.transform)
        {
            if (cTransform.gameObject.tag != "BaseMarker")
            {
                Destroy(cTransform.gameObject);
            }
        }

        // Create base
        foreach (var bState in state.blockStates)
        {
            var position = new Vector3(bState.x, bState.y, bState.z);
            var rotation = new Quaternion(bState.qx, bState.qy, bState.qz, bState.qw);

            // Skip blocks that are too far from the base
            if (position.magnitude > maxDistanceFromBase)
            {
                continue;
            }

            // TODO: No need to set position / rotation until it has a parent transform
            var block = CreateBlock(blockPrefabs, bState.blockType, position, rotation, layerNumber);
            block.transform.parent = baseObject.transform;
            block.transform.localPosition = position;
            block.transform.localRotation = rotation;

            block.AddComponent<MirrorObject>();
        }
    }
Пример #58
0
 public override void InitializeStates(out BaseState default_state)
 {
     default_state = empty;
     empty.EventTransition(GameHashes.OccupantChanged, full, (SMInstance smi) => smi.master.plantablePlot.Occupant != null).PlayAnim("off");
     full.EventTransition(GameHashes.OccupantChanged, empty, (SMInstance smi) => smi.master.plantablePlot.Occupant == null).PlayAnim("on");
 }
Пример #59
0
    //private string Serialize<T>(T data)
    //{
    //    return MiniJSON.Json.Serialize(data);
    //    //return fastJSON.JSON.Instance.ToJSON(data);
    //}
    public static void Test_SerializeBaseState()
    {
        var orig = new BaseState()
        {
            blockStates = new BlockState[] {
                new BlockState(){ blockType= BlockType.Hexagon, x=1.5f, y=1.5f, z=1.5f, qx=2.5f, qy=2.5f, qz=2.5f, qw=2.5f},
                new BlockState(){ blockType= BlockType.Square, x=1.5f, y=1.5f, z=1.5f, qx=2.5f, qy=2.5f, qz=2.5f, qw=2.5f},
            }
        };

        var text = Serialize(orig);

        var final = DeSerializeBaseState(text);

        // Verify
        for (int i = 0; i < orig.blockStates.Length; i++)
        {
            if (orig.blockStates[i].blockType != final.blockStates[i].blockType
                || orig.blockStates[i].qx != final.blockStates[i].qx)
            {
                throw new Exception("FAIL");
            }
        }
    }
 public override IEnumerator EnterState(BaseState prevState)
 {
     MoveTo(data.transform.position);
     return(base.EnterState(prevState));
 }