Beispiel #1
0
        internal static bool IsJson(string json, out int errIndex)
        {
            errIndex = 0;
            if (!string.IsNullOrEmpty(json) && json.Length > 1 &&
                ((json[0] == '{' && json[json.Length - 1] == '}') || (json[0] == '[' && json[json.Length - 1] == ']')))
            {
                CharState cs = new CharState();
                char c;
                for (int i = 0; i < json.Length; i++)
                {
                    c = json[i];
                    if (SetCharState(c, ref cs) && cs.childrenStart)//���ùؼ�����״̬��
                    {
                        string item = json.Substring(i);
                        int err;
                        int length = GetValueLength(item, true, out err);
                        cs.childrenStart = false;
                        if (err > 0)
                        {
                            errIndex = i + err;
                            return false;
                        }
                        i = i + length - 1;
                    }
                    if (cs.isError)
                    {
                        errIndex = i;
                        return false;
                    }
                }

                return !cs.arrayStart && !cs.jsonStart;
            }
            return false;
        }
    IEnumerator CheckState()
    {
        while (true)
        {
            yield return new WaitForSeconds(0.02f);

            

            switch (state)
            {
                case CharState.Idle:
                    break;
                case CharState.Move:
                    GetComponent<Rigidbody2D>().velocity -= new Vector2(speed * Time.deltaTime, 0);
                    break;
                case CharState.Die:
                    if (GetComponent<SpriteRenderer>().color.a > 0)
                    {
                        GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, alpha -= 0.1f);
                    }
                    else
                    {
                        gameManager.enemyList.Remove(this.gameObject);
                        DestroyObject(gameObject);
                    }
                    break;
                case CharState.Hit:
                    GetComponent<Rigidbody2D>().AddForce(new Vector2(0.5f, 0.5f) * 200);
                    state = CharState.Move;
                    if (GetComponent<Enemy>().hp <= 0)
                        state = CharState.Die;
                    break;
            }
        }
    }
    private void Awake()
    {
        if (Instance == null)
            Instance = this;

        charStateScript = GameObject.FindObjectOfType<CharState> ();
        camScript = GameObject.FindObjectOfType<ThirdPersonCamera> ();
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        charState = animator.GetComponent<CharState>();

        if (charState.Is(CharState.State.IdleJumping))
        {
            animator.speed = 1;
        }
    }
    public void Awake()
    {
        state = CharState.Idle;
        speed = 3f;
        alpha = 1;

        audioplayer = GetComponent<AudioSource>();

        StartCoroutine(CheckState());
    }
	//---------------------------------------------------------------------------------------------------------------------------
	// Private Methods
	//---------------------------------------------------------------------------------------------------------------------------	
	
	private void Awake ()
	{
		cam = Camera.main.transform;
		animator = GetComponent<Animator>();
		charState = GetComponent<CharState>();
		rb = GetComponent<Rigidbody>();
		
		maxJumpForce = jumpForce + 20f;
		
	}
    //---------------------------------------------------------------------------------------------------------------------------
    // Private Methods
    //---------------------------------------------------------------------------------------------------------------------------
    private void Awake()
    {
        origCamSmoothDampTime = camSmoothDampTime;

        //follow = GameObject.FindGameObjectWithTag("Follow").transform;
        curLookDir = follow.forward;

        // Get player's character state
        charState = GameObject.FindObjectOfType<CharState> ();
        //print (follow);
    }
    public void Start()
    {
        state = CharState.Move;
        speed = 10f;

        alpha = 1;

        gameManager = FindObjectOfType<GameManager>().GetComponent<GameManager>();

        StartCoroutine(CheckState());
    }
Beispiel #9
0
    private void Run()
    {
        Vector3 direction = transform.right * Input.GetAxis("Horizontal");

        transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, playerspeed * Time.deltaTime);

        sprite.flipX = direction.x > 0.0F;

        if (isGrounded)
        {
            State = CharState.Run;
        }
    }
 void propManipulated(Message m)
 {
     if (gameObject.tag == m.MessageValue)
     {
         countmessage += 1;
         if (countmessage == 2)
         {
             myCharState  = CharState.Manipulated;
             timer        = 0;
             countmessage = 0;
         }
     }
 }
    public override void ReceiveDamage()
    {
        Lives--;

        rigidbody.velocity = Vector3.zero;
        rigidbody.AddForce(transform.up * 10.0F, ForceMode2D.Impulse);

        if (livesCount == 0)
        {
            State = CharState.Die;
            Destroy(gameObject, 1.0F);
        }
    }
Beispiel #12
0
    private void Run()
    {
        Vector3 direction = transform.right * Input.GetAxis("Horizontal"); //в заивисмости от нажатой клавиши Input.GetAxis получает -1 или 1

        transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, speed * Time.deltaTime);
        //MoveTowards(откуда, куда (тек.положение+ направление),какое расстояние нужно пройти за один кадр(скорость на время между кадрами))

        sprite.flipX = direction.x < 0.0F;

        if (isGrounded)
        {
            State = CharState.Run;
        }
    }
Beispiel #13
0
    IEnumerator Flex()
    {
        if (onAttackCallback != null)
        {
            charState            = CharState.FLEX;
            currentSprite.sprite = flexFrame;

            yield return(new WaitForSeconds(0.5f));

            StatModifier mod = new StatModifier(charStats.GetBulkValue(), StatModifierType.flat);
            charStats.AddTempEndMod(mod);
        }
        ReturnToIdle();
    }
 void Start()
 {
     _rigidbody      = GetComponent <Rigidbody2D>();
     plStartPosition = this.transform.position;
     jumpForce       = 250.0f;//Раньше стояло 530. Но персонажа стало подбрасывать выше при том же весе
     speed           = 3.0f;
     curentHealth    = maxHealth;
     healthBar.SetMaxHealth(maxHealth);
     anim       = GetComponent <Animator>();
     State      = CharState.Stand;
     isDie      = false;
     isKneeing  = false;
     bulSpawnUp = bulSpawn.transform.localPosition;
 }
Beispiel #15
0
    private void Decelerate()
    {
        moveSpeed = Mathf.Lerp(moveSpeed, 0f, Time.deltaTime * acceleration);

        if (moveSpeed < 0.01f)
        {
            moveSpeed = 0f;

            if (charState != CharState.Custom)
            {
                charState = CharState.Idle;
            }
        }
    }
Beispiel #16
0
 protected override void OnDeath()
 {
     if (CurrentState != CharState.Dead)
     {
         CurrentState = CharState.Dead;
         SetAnimation("Dead");
     }
     else if (CurrentAnimation.AnimationName == "Dead" && CurrentAnimation.AnimationState == AnimationState.Finished)
     {
         context.lvl.CollisionWorld.Remove(CollisionBox);
         IsAlive = false;
         context.lvl.SpawnPlayer(null);
     }
 }
Beispiel #17
0
 private void FallOff()
 {
     State = CharState.Air;
     SetAnim("fly");
     Trajectory.Y = 0f;
     if (Trajectory.X > 300f)
     {
         Trajectory.X = 300f;
     }
     if (Trajectory.X < -300f)
     {
         Trajectory.X = -300f;
     }
 }
        protected IEnumerator Punch(CharState charState)
        {
            if (isGrounded)
            {
                State            = charState;
                _controlIsLocked = true;
                yield return(new WaitForSeconds(Helper.GetAnimLength(State.ToString(), this.gameObject)));

                _controlIsLocked = false;
            }


            yield return(null);
        }
Beispiel #19
0
    /// Функция проверка нахождения игрока на земле
    private void CheckGround()
    {
        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, 0.3F);

        if (colliders.All(x => !x.GetComponent <Shield>()))
        {
            isGrounded = colliders.Length > 1;
        }

        if (!isGrounded)
        {
            State = CharState.Jump;
        }
    }
 public IEnumerator Respawn()
 {
     Debug.Log(name + " Score : " + characterScore.ToString());
     characterState = CharState.Idle;
     WayPoint.SetActive(false);
     GetComponent <MeshRenderer>().material.color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
     transform.position = RespawnPos;
     moveDestination    = transform.position;
     characterCamera.transform.position = transform.position + new Vector3(0, CameraHeight, CameraDistance);
     characterCamera.transform.LookAt(transform.position);
     transform.rotation = Quaternion.identity;
     nHP = mHP;
     yield return(null);
 }
Beispiel #21
0
    public void CharStart(bool iH, Camera cam)
    {
        _isPlaying = true;

        //Set the camera's hold position
        _mainCam    = cam;
        _camIdlePos = _mainCam.transform.position;

        //Set up the sprites
        Char.transform.position = IdlePos.position;
        _isHappy  = iH;
        _curState = CharState.Idle;
        charSprites.StartCharacter(CharState.Idle, animationFrameTime);
        //charSprites.ChangeState(CharState.Idle);
    }
Beispiel #22
0
    private void CheckGround()
    {
        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, 1.2f);

        isGrounded = colliders.Length > 2;
        //Debug.Log(colliders.Length);
        if (!isGrounded)
        {
            state = CharState.Jump;
        }
        else
        {
            state = CharState.Run;
        }
    }
Beispiel #23
0
 // Start is called before the first frame update
 void Start()
 {
     foreach (Transform child in transform)
     {
         if (child.TryGetComponent(out EventCollider eventcollider))
         {
             _event = eventcollider;
             break;
         }
     }
     _move   = gameObject.GetComponent <CharController>();
     _action = GetComponent <CharAction>();
     _state  = CharState.NOMAL;
     _action.Play();
 }
    IEnumerator Die()
    {
        GetComponent <BoxCollider2D>().enabled = false;
        isDie        = true;
        curentHealth = -1;
        State        = CharState.Die;
        yield return(new WaitForSeconds(2f));

        this.transform.position = plStartPosition;
        isDie        = false;
        curentHealth = maxHealth;
        healthBar.SetHealth(curentHealth);
        print("curentHealth = maxHealth " + curentHealth);
        GetComponent <BoxCollider2D>().enabled = true;
    }
Beispiel #25
0
    /////////////////////////////////////////////////////////////////
    private void Run()
    {
        if (dead1)
        {
            Vector3 direction = transform.right * Input.GetAxis("Horizontal");

            transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, speed * Time.deltaTime);

            sprite.flipX = direction.x <= 0.0f; // Personaj spritini x o'qi bilan ko'zgulashadi.
            if (isGrounded)                     // agar yerda bo'lsa yugurish animatsiyasi bajariladi
            {
                State = CharState.Run;
            }
        }
    }
 IEnumerator CoHit(float time)
 {
     isHit = true;
     anim.SetBool("Stunned", true);
     state       = CharState.hit;
     stunnedTime = time;
     while (stunnedTime > 0f)
     {
         stunnedTime -= Time.deltaTime;
         yield return(null);
     }
     isHit = false;
     anim.SetBool("Stunned", false);
     state = CharState.idle;
 }
 void Move(float horizontalInput)
 {
     if (knockbackCount <= 0)
     {
         forwardVelocity += accelRatePerSec * Time.deltaTime;
         forwardVelocity  = Mathf.Min(forwardVelocity, maxSpeed);
         Vector2 moveVel = rb2d.velocity;
         moveVel.x     = horizontalInput * forwardVelocity;
         rb2d.velocity = moveVel;
         if (isGrounded && (hInput > 0 || hInput < 0))
         {
             State = CharState.Run;
         }
     }
 }
Beispiel #28
0
 private void Update()
 {
     if (isGrounded)
     {
         State = CharState.Idle;
     }
     if (Input.GetButton("Horizontal"))
     {
         Run();
     }
     if (isGrounded && Input.GetButtonDown("Jump"))
     {
         Jump();
     }
 }
Beispiel #29
0
 public override void ResivDameg()
 {
     if (Hp > 0)
     {
         Hp = (Hp - 20);
         sound_damage.Play();
         rigidbody.velocity = Vector3.zero;
         rigidbody.AddForce(transform.up * 45F, ForceMode2D.Impulse);
         transform.position += -position * Time.deltaTime * 65F;
     }
     else
     {
         State = CharState.die;
     }
 }
Beispiel #30
0
 private void Update()
 {
     State = CharState.Idle;
     if (Input.GetButton("Horizontal"))
     {
         Run();
     }
     if (isGrounded && Input.GetButtonUp("Jump"))
     {
         Jump();
     }
     AttackLeft();
     AttackRight();
     RespawnCheck();
 }
Beispiel #31
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftControl) && pause.activeSelf == false && finishPanel.activeSelf == false)
        {
            Shoot();
        }
        if (isGrounded)
        {
            State = CharState.Idle;
        }
        if ((Input.GetKeyUp("s")) || (Input.GetKeyUp("down")) && pause.activeSelf == false && finishPanel.activeSelf == false)
        {
            speed = 3.0F;
        }
        if (Input.GetButton("Horizontal") && pause.activeSelf == false && finishPanel.activeSelf == false)
        {
            Run();
        }
        if (isGrounded && Input.GetButtonDown("Jump") && pause.activeSelf == false && finishPanel.activeSelf == false)
        {
            Jump();
        }
        if (isGrounded && Input.GetButton("Vertical") && pause.activeSelf == false && finishPanel.activeSelf == false)
        {
            Squat();
        }
        coinText.text = "COINS " + score;



        if (pause.activeSelf == true || finishPanel.activeSelf == true)
        {
            UnityEngine.Cursor.visible = true;
        }
        else if (pause.activeSelf == false || finishPanel.activeSelf == false)
        {
            UnityEngine.Cursor.visible = false;
        }

        if (pause.activeSelf == true && Input.GetKeyDown(KeyCode.Escape))
        {
            pause.gameObject.SetActive(false);
        }
        else if (pause.activeSelf == false && Input.GetKeyDown(KeyCode.Escape))
        {
            pause.gameObject.SetActive(true);
        }
    }
    private void Update()
    {
        if (HealthBarScript.health <= 0)
        {
            Destroy(gameObject);
            SceneManager.LoadScene("Castle");
        }
        if (hInput == 0)
        {
            forwardVelocity = 0f;
        }
        if (hInput == 0 && isGrounded && !mbAttack)
        {
            State = CharState.Idle;
        }
        if (mbAttack)
        {
            State = CharState.Attack;
        }
        if (isGrounded && (Input.GetButtonDown("Jump") || mbJump))
        {
            jump = true;
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            Debug.Log(rb2d.velocity.y);
        }
        if (knockbackCount <= 0)
        {
            rb2d.velocity = new Vector2(rb2d.velocity.x, rb2d.velocity.y);
        }
        else
        {
            Instantiate(blood, transform.position, Quaternion.identity);
            State = CharState.Hit;
            if (knockFromRight)
            {
                rb2d.velocity = new Vector2(-knockbackX, knockbackY);
            }

            if (!knockFromRight)
            {
                rb2d.velocity = new Vector2(knockbackX, knockbackY);
            }

            knockbackCount -= Time.deltaTime;
        }
    }
Beispiel #33
0
    private void Run()
    {
        if (!(daying == 1))
        {
            if (isGrounded)
            {
                State = CharState.Run;
            }
            direction = transform.right * Input.GetAxis("Horizontal");


            transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, speed * Time.deltaTime);

            spriterender.flipX = direction.x < 0;
        }
    }
Beispiel #34
0
    private void CheckGround()
    {
        Vector3 playerPosition = transform.position;

        playerPosition.y -= 1.2F;
        Collider2D[] colliders = Physics2D.OverlapCircleAll(playerPosition, 0.1F);

        isGrounded = colliders.Length > 1;
        //Debug.Log (State);


        if (!isGrounded)
        {
            State = CharState.Jump;
        }
    }
        protected void CheckGround()
        {
            if (Legs.Where(x => x.IsGrounded).Count() > 0)
            {
                isGrounded = true;
            }
            else
            {
                isGrounded = false;
            }

            if (!isGrounded)
            {
                State = CharState.Jump;
            }
        }
Beispiel #36
0
    private void Update()
    {
        State = CharState.Stay;
        if (Input.GetButton("Horizontal"))
        {
            Move();
        }


        if (isGrounded && Input.GetButton("Jump"))
        {
            Jump();
        }

        Die();
    }
Beispiel #37
0
    private void Run()
    {
        //В зависимости от того куда бежим в право или в лево возвращаем 1 или -1
        //Transform определяет Position (положение), Rotation (вращение), и Scale (масштаб) каждого объекта в сцене. У каждого GameObject’а есть Transform.
        Vector3 direction = transform.right * Input.GetAxis("Horizontal");

        //Насколько нужно сдвинуть. Time.deltaTime - время между текущим и предыдущим фреймом (кадром)
        transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, speed * Time.deltaTime);
        //Инвертировать модельку персонажа при изменении направления движения
        sprite.flipX = direction.x < 0.0F;
        //Меняем состояние игрока на бежит
        if (isGrounded)
        {
            State = CharState.Ran;
        }
    }
 void OnCollisionStay2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         if (col.gameObject.GetComponent<EnemyAction>().state != CharState.Die
        && state != CharState.Die)
         {
             col.gameObject.GetComponent<Enemy>().hp -= gameObject.GetComponent<Friendly>().ap;
             col.gameObject.GetComponent<EnemyAction>().state = CharState.Hit;
             gameObject.GetComponent<Friendly>().hp -= col.gameObject.GetComponent<Enemy>().ap;
             state = CharState.Hit;
             audioplayer.clip = hitsound[Random.Range(0, 3)];
             audioplayer.Play();
         }
     }
 }
Beispiel #39
0
 private void Update() //буде вся логыка, оброблювач подій, рух і постріл
 {
     if (Input.GetButtonDown("Fire1"))
     {
         Shoot();
     }
     State = CharState.idle; //установлюється анімація айдл
     if (Input.GetButton("Horizontal"))
     {
         Run();
     }
     if (Input.GetButtonDown("Jump"))
     {
         Jump();
     }
 }
Beispiel #40
0
        private void Decelerate()
        {
            if (animEngine != null && animEngine.turningStyle == TurningStyle.Linear)
            {
                moveSpeed = Mathf.Lerp (moveSpeed, 0f, Time.deltaTime * GetDeceleration () * 3f);
            }
            else
            {
                if (AccurateDestination () && !CanBeDirectControlled () && charState == CharState.Decelerate)
                {
                    AccurateAcc (moveSpeed, true);
                }
                else
                {
                    moveSpeed = Mathf.Lerp (moveSpeed, 0f, Time.deltaTime * GetDeceleration ());
                }
            }

            if (moveSpeed <= 0f)
            {
                moveSpeed = 0f;

                if (charState != CharState.Custom)
                {
                    charState = CharState.Idle;
                }
            }
        }
Beispiel #41
0
        public void Halt()
        {
            if (GetComponent <Paths>() && activePath == GetComponent <Paths>()) {}
            else
            {
                lastPathPrevNode = prevNode;
                lastPathTargetNode = targetNode;
                lastPathActivePath = activePath;
            }

            activePath = null;
            targetNode = 0;
            moveSpeed = 0f;

            if (charState == CharState.Move || charState == CharState.Decelerate)
            {
                charState = CharState.Idle;
            }
        }
Beispiel #42
0
        private void PausePath(float pauseTime, ActionListAsset pauseAsset, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;

            if (pauseAsset.useParameters && parameterID >= 0 && pauseAsset.parameters.Count > parameterID)
            {
                int idToSend = 0;
                if (this.gameObject.GetComponent <ConstantID>())
                {
                    idToSend = this.gameObject.GetComponent <ConstantID>().constantID;
                }
                else
                {
                    ACDebug.LogWarning (this.gameObject.name + " requires a ConstantID script component!");
                }
                pauseAsset.parameters [parameterID].SetValue (idToSend);
            }

            if (pauseTime > 0f)
            {
                pausePathTime = Time.time + pauseTime + 1f;
                StartCoroutine (DelayPathActionList (pauseTime, pauseAsset));
            }
            else
            {
                pausePathTime = 0f;
                nodeActionList = AdvGame.RunActionListAsset (pauseAsset);
            }
        }
Beispiel #43
0
 private void Backup()
 {
     if (charState != CharState.None || sb.Length == 0)
         throw new InvalidOperationException("no character to backup");
     else
     {
         c = sb[sb.Length - 1];
         cat = Char.GetUnicodeCategory(c);
         charState = CharState.Some;
         sb.Remove(sb.Length - 1, 1);
         currentPos--;
         currentColumn--;
     }
 }
Beispiel #44
0
        protected void AccurateAcc(float targetSpeed, bool canStop)
        {
            if (IsTurningBeforeWalking ())
            {
                return;
            }

            float lerpDistance = 3f * ((isRunning) ? (runSpeedScale / walkSpeedScale) : 1f) / GetDeceleration ();
            float dist = Vector3.Distance (GetSmartPosition (exactDestination), transform.position);

            if (canStop && dist == 0f)
            {
                charState = CharState.Idle;
                transform.position = GetSmartPosition (exactDestination);
                moveSpeed = 0f;
                isExactLerping = false;
                return;
            }
            else if (canStop && (dist < lerpDistance / 4f || dist > lastDist))
            {
                isExactLerping = true;
                transform.position = Vector3.Lerp (transform.position, GetSmartPosition (exactDestination), Time.deltaTime * GetDeceleration ());
            }
            else
            {
                isExactLerping = false;
            }

            if (dist < lastDist)
            {
                float fac = 1f;
                if (dist < lerpDistance)
                {
                    isRunning = false;
                    fac = dist / lerpDistance;
                }
                moveSpeed = Mathf.Lerp (moveSpeed, targetSpeed * fac, Time.deltaTime * ((canStop) ? GetDeceleration () : acceleration));
            }

            if (canStop)
            {
                moveDirection = (GetSmartPosition (exactDestination) - transform.position);
                lastDist = dist;
            }
        }
Beispiel #45
0
        private void PausePath(Cutscene pauseCutscene, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;
            pausePathTime = 0f;

            if (pauseCutscene.useParameters && parameterID >= 0 && pauseCutscene.parameters.Count > parameterID)
            {
                pauseCutscene.parameters [parameterID].SetValue (this.gameObject);
            }

            pauseCutscene.Interact ();
            nodeActionList = pauseCutscene;
        }
        private void ReadBACData()
        {
            var BAC = (int)Util.Memory.ReadInt((int)Util.Memory.ReadInt(_BaseOffset + 0xB0) + 0x8);

            if (BAC != bac_off && BAC != 0)
            {
                //Gotta load BCM
                var tmpfile = File.Create(System.IO.Path.GetTempPath() + "/tmp.bac", 0x4000);
                var tmparr = Util.Memory.ReadAOB(BAC, 0xA0000);
                tmpfile.Write(tmparr, 0, tmparr.Length);
                tmpfile.Close();
                bac = BACFile.FromFilename(System.IO.Path.GetTempPath() + "/tmp.bac", bcm);
                bac_off = BAC;
            }
            //Not in a match
            if (BAC == 0)
                return;

            var BAC_data = (int)Util.Memory.ReadInt(_BaseOffset + 0xB0);
            var XChange = X;

            X = Util.Memory.ReadFloat(_BaseOffset + 0x16D0);
            Y = Util.Memory.ReadFloat(_BaseOffset + 0x74);
            XChange = XChange - X;
            XVelocity = Util.Memory.ReadFloat(_BaseOffset + 0xe0);
            if (XVelocity == 0 && XChange != 0)
            {
                XVelocity = XChange;
                //Console.WriteLine("Using {0} for XVel due to XChange", XChange);
            }
            YVelocity = Util.Memory.ReadFloat(_BaseOffset + 0xe4);
            XAcceleration = Util.Memory.ReadFloat(_BaseOffset + 0x100);
            YAcceleration = Util.Memory.ReadFloat(_BaseOffset + 0x104);

            Meter = (int)Util.Memory.ReadShort(_BaseOffset + 0x6C3A);
            Revenge = (int)Util.Memory.ReadShort(_BaseOffset + 0x6C4E);


            Flags = (StatusFlags)Util.Memory.ReadInt(_BaseOffset + 0xBC);
            LastScriptIndex = ScriptIndex;

            ScriptIndex = (int)Util.Memory.ReadInt(BAC_data + 0x18);
            LastScriptName = ScriptName;
            var script = bac.Scripts.Where(x => x.Index == ScriptIndex).FirstOrDefault();
            if (script == null)
                ScriptName = ScriptIndex.ToString();
            else
                ScriptName = script.Name;
            if (ScriptName == "")
                return;
            ScriptTickTotal = Util.Memory.ReadInt(BAC_data + 0x24) / 0x10000;
            ScriptTickHitboxStart = Util.Memory.ReadInt(BAC_data + 0x28) / 0x10000;
            ScriptTickHitboxEnd = Util.Memory.ReadInt(BAC_data + 0x2C) / 0x10000;
            ScriptTickIASA = Util.Memory.ReadInt(BAC_data + 0x30) / 0x10000;
            ScriptTick = Util.Memory.ReadInt(BAC_data + 0x3C) / 0x10000;

            ScriptSpeed = Util.Memory.ReadInt(BAC_data + 0x18 + 0xC0) / 0x10000;


            if (ScriptTickIASA == 0)
                ScriptTickIASA = ScriptTickTotal;

            ComputeTickstoFrames(BAC);
            ComputeAttackData(BAC);

            if (ScriptFrameHitboxStart != 0)
            {
                if (ScriptFrame <= ScriptFrameHitboxStart)
                {
                    State = CharState.Startup;
                    StateTimer = ScriptFrameHitboxStart - ScriptFrame;

                }
                else if (ScriptFrame <= ScriptFrameHitboxEnd)
                {
                    State = CharState.Active;
                    StateTimer = ScriptFrameHitboxEnd - ScriptFrame;
                }
                else if (ScriptFrameIASA > 0 && ScriptFrame <= ScriptFrameIASA)
                {
                    State = CharState.Recovery;
                    StateTimer = ScriptFrameIASA - ScriptFrame;
                }
                else if (ScriptFrame <= ScriptFrameTotal)
                {
                    State = CharState.Recovery;
                    StateTimer = ScriptFrameTotal - ScriptFrame;
                }
                else
                {
                    State = CharState.Neutral;
                }
            }
            else
            {
                State = CharState.Neutral;
                StateTimer = -1;
                AState = AttackState.None;
            }
        }
Beispiel #47
0
        private void Decelerate()
        {
            if (doExactLerp)
            {
                moveSpeed = 0;
                return;
            }

            else if (animEngine != null && animEngine.turningStyle == TurningStyle.Linear)
            {
                moveSpeed = Mathf.Lerp (moveSpeed, 0f, Time.deltaTime * GetDeceleration () * 3f);
            }

            else
            {
                moveSpeed = Mathf.Lerp (moveSpeed, 0f, Time.deltaTime * GetDeceleration ());
            }

            if (moveSpeed < 0.01f)
            {
                moveSpeed = 0f;

                if (charState != CharState.Custom)
                {
                    charState = CharState.Idle;
                }
            }
        }
Beispiel #48
0
        protected void _Awake()
        {
            if (GetComponent <CharacterController>())
            {
                _characterController = GetComponent <CharacterController>();
                wallRayOrigin = _characterController.center;
                wallRayForward = _characterController.radius;
            }
            else if (GetComponent <CapsuleCollider>())
            {
                CapsuleCollider capsuleCollider = GetComponent <CapsuleCollider>();
                wallRayOrigin = capsuleCollider.center;
                wallRayForward = capsuleCollider.radius;
            }

            if (GetComponentInChildren <FollowSortingMap>())
            {
                transform.localScale = Vector3.one;
            }
            originalScale = transform.localScale;
            charState = CharState.Idle;
            shapeable = GetShapeable ();
            if (GetComponent <LipSyncTexture>())
            {
                lipSyncTexture = GetComponent <LipSyncTexture>();
            }

            ResetAnimationEngine ();
            ResetBaseClips ();

            if (spriteChild && spriteChild.GetComponent <Animator>())
            {
                animator = spriteChild.GetComponent <Animator>();
            }

            if (soundChild && soundChild.gameObject.GetComponent <AudioSource>())
            {
                audioSource = soundChild.gameObject.GetComponent <AudioSource>();
            }

            if (GetComponent <Animator>())
            {
                animator = GetComponent <Animator>();
            }

            if (GetComponent <Animation>())
            {
                _animation = GetComponent <Animation>();
            }

            if (GetComponent <Rigidbody>())
            {
                _rigidbody = GetComponent <Rigidbody>();
            }
            else if (GetComponent <Rigidbody2D>())
            {
                _rigidbody2D = GetComponent <Rigidbody2D>();
            }

            if (GetComponent <Collider>())
            {
                _collider = GetComponent <Collider>();
            }

            AdvGame.AssignMixerGroup (GetComponent <AudioSource>(), SoundType.Other, true);
            AdvGame.AssignMixerGroup (audioSource, SoundType.SFX);
        }
Beispiel #49
0
        /**
         * <summary>Stops the character from moving along the current Paths object.</summary>
         */
        public void EndPath()
        {
            if (GetComponent <Paths>() && activePath == GetComponent <Paths>())
            {
                activePath.nodes.Clear ();
            }
            else
            {
                lastPathPrevNode = prevNode;
                lastPathTargetNode = targetNode;
                lastPathActivePath = activePath;
            }

            activePath = null;
            targetNode = 0;
            pathfindUpdateTime = 0f;
            StopTurning ();

            if (charState == CharState.Move)
            {
                charState = CharState.Decelerate;
            }
        }
Beispiel #50
0
        protected void _Awake()
        {
            if (GetComponent <CharacterController>())
            {
                _characterController = GetComponent <CharacterController>();
                wallRayOrigin = _characterController.center;
                wallRayForward = _characterController.radius;
            }
            else if (GetComponent <CapsuleCollider>())
            {
                CapsuleCollider capsuleCollider = GetComponent <CapsuleCollider>();
                wallRayOrigin = capsuleCollider.center;
                wallRayForward = capsuleCollider.radius;
            }
            else if (GetComponent <CircleCollider2D>())
            {
                CircleCollider2D circleCollider = GetComponent <CircleCollider2D>();
                #if !UNITY_5
                wallRayOrigin = circleCollider.center;
                #else
                wallRayOrigin = circleCollider.offset;
                #endif
                wallRayForward = circleCollider.radius;
            }
            else if (GetComponent <BoxCollider2D>())
            {
                BoxCollider2D boxCollider = GetComponent <BoxCollider2D>();
                wallRayOrigin = boxCollider.bounds.center;
                wallRayForward = boxCollider.bounds.size.x / 2f;
            }

            if (GetComponentInChildren <FollowSortingMap>())
            {
                transform.localScale = Vector3.one;
            }
            originalScale = transform.localScale;
            charState = CharState.Idle;
            shapeable = GetShapeable ();
            if (GetComponent <LipSyncTexture>())
            {
                lipSyncTexture = GetComponent <LipSyncTexture>();
            }

            ResetAnimationEngine ();
            ResetBaseClips ();

            _animator = GetAnimator ();
            _animation = GetAnimation ();
            SetAntiGlideState ();

            if (spriteChild && spriteChild.gameObject.GetComponent <SpriteRenderer>())
            {
                _spriteRenderer = spriteChild.gameObject.GetComponent <SpriteRenderer>();
                if (spriteChild.localPosition.magnitude > 0f)
                {
                    if (!(gameObject.name == "Bird" && spriteChild.gameObject.name == "Bird_Sprite"))
                    {
                        // You found the dirtest hack in AC!
                        ACDebug.LogWarning ("The sprite child of '" + gameObject.name + "' is not positioned at (0,0,0) - is this correct?");
                    }
                }
            }

            if (speechAudioSource == null && GetComponent <AudioSource>())
            {
                speechAudioSource = GetComponent <AudioSource>();
            }

            if (soundChild && soundChild.gameObject.GetComponent <AudioSource>())
            {
                audioSource = soundChild.gameObject.GetComponent <AudioSource>();
            }

            if (GetComponent <Rigidbody>())
            {
                _rigidbody = GetComponent <Rigidbody>();
            }
            else if (GetComponent <Rigidbody2D>())
            {
                _rigidbody2D = GetComponent <Rigidbody2D>();
            }
            PhysicsUpdate ();

            if (GetComponent <Collider>())
            {
                _collider = GetComponent <Collider>();
            }

            AdvGame.AssignMixerGroup (speechAudioSource, SoundType.Speech, true);
            AdvGame.AssignMixerGroup (audioSource, SoundType.SFX);
        }
Beispiel #51
0
        private void PausePath(ActionListAsset pauseAsset, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;
            pausePathTime = 0f;

            if (pauseAsset.useParameters && parameterID >= 0 && pauseAsset.parameters.Count > parameterID)
            {
                int idToSend = 0;
                if (this.gameObject.GetComponent <ConstantID>())
                {
                    idToSend = this.gameObject.GetComponent <ConstantID>().constantID;
                }
                else
                {
                    Debug.LogWarning (this.gameObject.name + " requires a ConstantID script component!");
                }
                pauseAsset.parameters [parameterID].SetValue (idToSend);
            }

            nodeActionList = AdvGame.RunActionListAsset (pauseAsset);
        }
Beispiel #52
0
        private void SetPath(Paths pathOb, PathSpeed _speed, int _targetNode, int _prevNode)
        {
            activePath = pathOb;
            targetNode = _targetNode;
            prevNode = _prevNode;

            doExactLerp = false;
            exactDestination = pathOb.nodes [pathOb.nodes.Count-1];

            if (CanTurnBeforeMoving ())
            {
                TurnBeforeWalking ();
            }

            if (pathOb)
            {
                if (_speed == PathSpeed.Run)
                {
                    isRunning = true;
                }
                else
                {
                    isRunning = false;
                }
            }

            if (charState == CharState.Custom)
            {
                charState = CharState.Idle;
            }
        }
Beispiel #53
0
 // Development Version 2.0.4
 // Set Shoe Color/Zombie Mode
 // Requirements 1.4.0 and 1.5.0
 public void setCharState(int state)
 {
     currentCharState = (CharState)state;
 }
Beispiel #54
0
        public void EndPath()
        {
            if (GetComponent <Paths>() && activePath == GetComponent <Paths>())
            {
                activePath.nodes.Clear ();
            }
            else
            {
                lastPathPrevNode = prevNode;
                lastPathTargetNode = targetNode;
                lastPathActivePath = activePath;
            }

            activePath = null;
            targetNode = 0;

            if (charState == CharState.Move)
            {
                charState = CharState.Decelerate;

                if (AccurateDestination ())
                {
                    moveSpeed = 0f;
                    doExactLerp = true;
                }
            }
        }
Beispiel #55
0
 private void Discard()
 {
     charState = CharState.None;
 }
Beispiel #56
0
 public void ForceIdle()
 {
     charState = CharState.Idle;
 }
Beispiel #57
0
        private void ExactLerp()
        {
            if (!doExactLerp)
            {
                return;
            }

            if (charState != CharState.Decelerate || moveSpeed > 0f)
            {
                doExactLerp = false;
                return;
            }

            moveSpeed = 0f;
            Vector3 smartPosition = exactDestination;

            if (KickStarter.settingsManager.IsUnity2D ())
            {
                smartPosition = new Vector3 (exactDestination.x, exactDestination.y, transform.position.z);
            }
            else
            {
                smartPosition = new Vector3 (exactDestination.x, transform.position.y, exactDestination.z);
            }

            if (IsUFPSPlayer ())
            {
                UltimateFPSIntegration.Teleport (smartPosition);
                doExactLerp = false;
                charState = CharState.Idle;
                return;
            }

            if (smartPosition == transform.position)
            {
                doExactLerp = false;
                if (charState == CharState.Decelerate)
                {
                    charState = CharState.Idle;
                }
            }
            else
            {
                float mag = (transform.position - smartPosition).magnitude * 10f;
                transform.position = Vector3.Lerp (transform.position, smartPosition, Time.deltaTime * GetDeceleration () / mag);
            }
        }
Beispiel #58
0
        private void PausePath(float pauseTime, Cutscene pauseCutscene, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;

            if (pauseCutscene.useParameters && parameterID >= 0 && pauseCutscene.parameters.Count > parameterID)
            {
                pauseCutscene.parameters [parameterID].SetValue (this.gameObject);
            }

            if (pauseTime > 0f)
            {
                pausePathTime = Time.time + pauseTime + 1f;
                StartCoroutine (DelayPathCutscene (pauseTime, pauseCutscene));
            }
            else
            {
                pausePathTime = 0f;
                pauseCutscene.Interact ();
                nodeActionList = pauseCutscene;
            }
        }
        private void ReadOtherData()
        {

            int off = 0x8;
            if (PlayerIndex == 1)
                off = 0xC;

            var ProjectileOffset = (int)Util.Memory.ReadInt((int)Util.Memory.ReadInt(0x400000 + 0x006A7DE8) + off);
            var tmp1 = (int)Util.Memory.ReadInt((int)ProjectileOffset + 0x4);
            var ProjectileCount = (int)Util.Memory.ReadInt((int)ProjectileOffset + 0x8C);
            if (ProjectileCount != 0)
            {
                var ProjectileLeft = Util.Memory.ReadFloat((int)tmp1 + 0x70);
                var ProjectileRight = Util.Memory.ReadFloat((int)tmp1 + 0x70 + 0x10);
                var ProjectileSpeed = Util.Memory.ReadFloat((int)tmp1 + 0x70 + 0x70);
                var right = Math.Abs(ProjectileRight - X);
                var left = Math.Abs(ProjectileLeft - X);
                var max = Math.Max(right, left);

                AttackRange = Math.Max(max + ProjectileSpeed * 10, AttackRange);
                State = CharState.Active;
            }
            for (int i = 0; i <= 5; i++)
            {

                var hitboxPtr = (int)Util.Memory.ReadInt(_BaseOffset + 0x130 + i * 4);
                var count = (int)Util.Memory.ReadInt(hitboxPtr + 0x2C);
                var start = (int)Util.Memory.ReadInt(hitboxPtr + 0x20);
                for (int j = 0; j < count; j++)
                {
                    if (i == 0)
                    {

                    }
                    //ReadBox here.
                }
            }

        }
Beispiel #60
0
 private void PausePath(float pauseTime)
 {
     charState = CharState.Decelerate;
     pausePath = true;
     pausePathTime = Time.time + pauseTime;
     nodeActionList = null;
 }