Beispiel #1
0
        public override void UpdateBehaviour(float dt)
        {
            // bool isTag = CharacterStateController.Animator.GetCurrentAnimatorStateInfo(0).tagHash == StateNameHash;

            switch (state)
            {
            case LedgeHangingState.Idle:

                if (CharacterActions.movement.Up || autoClimbUp || forceAutoClimbUp)
                {
                    state = LedgeHangingState.TopUp;
                    CharacterStateController.UseRootMotion = true;
                    CharacterStateController.Animator.SetTrigger(topUpParameter);
                }
                else if (CharacterActions.movement.Down)
                {
                    forceExit = true;
                }

                break;

            case LedgeHangingState.TopUp:

                if (CharacterStateController.Animator.GetCurrentAnimatorStateInfo(0).IsName("Exit"))
                {
                    forceExit = true;
                    CharacterActor.ForceGrounded();
                }


                break;
            }
        }
Beispiel #2
0
        protected virtual void HandleSize(float dt)
        {
            // Want to crouch ---------------------------------------------------------------------
            if (CharacterActor.IsGrounded && crouchParameters.enableCrouch)
            {
                if (crouchParameters.inputMode == InputMode.Toggle)
                {
                    if (CharacterActions.crouch.Started)
                    {
                        wantToCrouch = !wantToCrouch;
                    }
                }
                else
                {
                    wantToCrouch = CharacterActions.crouch.value;
                }
            }
            else
            {
                wantToCrouch = false;
            }

            // Process Size ----------------------------------------------------------------------------
            targetHeight = wantToCrouch ? CharacterActor.DefaultBodySize.y * crouchParameters.heightRatio : CharacterActor.DefaultBodySize.y;

            Vector3 targetSize = new Vector2(CharacterActor.DefaultBodySize.x, targetHeight);

            bool validSize = CharacterActor.SetBodySize(targetSize);

            if (validSize)
            {
                isCrouched = wantToCrouch;
            }
        }
    public override bool DoInteracted(CharacterActor characterActor, Direction direction, GameObject interactor)
    {
        CharacterActor otherCharacterActor = interactor.GetComponent <CharacterActor>();

        if (otherCharacterActor)
        {
            Collider2D collision = otherCharacterActor.thisInteractionCollider2D;

            // Demote enemies to a smaller state or kill them if they are
            // below or the same y distance as Goomba
            if (characterActor.IsBrainEnemy(otherCharacterActor.brain))
            {
                if (Utilities.CheckOtherColliderDirection2D(Direction.Down, characterActor.thisInteractionCollider2D, collision))
                {
                    if (otherCharacterActor.formStateMachine.currentState != otherCharacterActor.smallFormState)
                    {
                        otherCharacterActor.SetForm(otherCharacterActor.smallFormState);
                        Debug.Log("small");
                        return(true);
                    }
                    else
                    {
                        otherCharacterActor.statusStateMachine.SetState(otherCharacterActor.deadStatusState);
                        Debug.Log("dead");
                        return(true);
                    }
                }
            }
        }

        return(false);
    }
Beispiel #4
0
    public override bool DoInteracted(PowerupActor powerupActor, Direction direction, GameObject interactor)
    {
        CharacterActor otherCharacterActor = interactor.transform.root.GetComponent <CharacterActor>();

        if (otherCharacterActor)
        {
            // Empower buffables upon contact
            if (powerupActor.IsBrainBuffable(otherCharacterActor.brain))
            {
                if (otherCharacterActor.formStateMachine.currentState == otherCharacterActor.smallFormState)
                {
                    otherCharacterActor.SetForm(otherCharacterActor.bigFormState);
                    Destroy(powerupActor.gameObject);
                    return(true);
                }
                else if (otherCharacterActor.formStateMachine.currentState == otherCharacterActor.bigFormState)
                {
                    otherCharacterActor.SetForm(otherCharacterActor.powerFormState);
                    Destroy(powerupActor.gameObject);
                    return(true);
                }
            }
        }

        return(false);
    }
Beispiel #5
0
    public override void DoInteractorCasterHit(CharacterActor characterActor, Direction direction, RaycastHit2D hit, Collider2D collider)
    {
        Interactable interactable = collider.GetComponentInParent <Interactable>();

        if (interactable)
        {
            switch (direction)
            {
            case Direction.Up:
                interactable.Interact(Direction.Down, characterActor.thisGameObject);
                break;

            case Direction.Down:
                interactable.Interact(Direction.Up, characterActor.thisGameObject);
                break;

            case Direction.Left:
                interactable.Interact(Direction.Right, characterActor.thisGameObject);
                break;

            case Direction.Right:
                interactable.Interact(Direction.Left, characterActor.thisGameObject);
                break;
            }
        }
    }
        public ICollection <Character> Parse(string animeHtml)
        {
            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(animeHtml);

            var characterNodes = doc.DocumentNode.SelectNodes("//*[@id=\"content\"]/table/tr/td[2]/div[1]/table[count(preceding-sibling::h2)=1]")?.ToArray() ?? new HtmlNode[0];

            HashSet <Character> characters = new HashSet <Character>();

            for (int i = 0; i < characterNodes.Count(); i++)
            {
                var       characterTd = characterNodes[i].SelectSingleNode("./tr/td[2]");
                Character character   = new Character();
                parseCharacter(character, characterTd);

                var actorsRows = characterNodes[i].SelectNodes("./tr/td[3]/table/tr")?.ToArray() ?? new HtmlNode[0];
                foreach (var actorRow in actorsRows)
                {
                    CharacterActor characterActor = actorFromRow(actorRow);
                    characterActor.Character   = character;
                    characterActor.CharacterId = character.CharacterID;
                    character.Actors.Add(characterActor);
                }
                characters.Add(character);
            }

            return(characters);
        }
Beispiel #7
0
        void Awake()
        {
            if (targetTransform == null)
            {
                Debug.Log("The target graphics object is not active and enabled.");
                this.enabled = false;

                return;
            }

            characterActor = targetTransform.GetComponentInBranch <CharacterActor>();

            if (characterActor == null || !characterActor.isActiveAndEnabled)
            {
                Debug.Log("The character actor component is null, or it is not active/enabled.");
                this.enabled = false;

                return;
            }

            inputHandlerSettings.Initialize(gameObject);

            GameObject referenceObject = new GameObject("Camera referece");

            viewReference = referenceObject.transform;

            if (bodyObject != null)
            {
                bodyRenderers = bodyObject.GetComponentsInChildren <Renderer>();
            }
        }
Beispiel #8
0
        public override void UpdateBehaviour(float dt)
        {
            switch (state)
            {
            case LadderClimbState.Entering:

                CharacterActor.Position = targetPosition;
                CharacterStateController.UseRootMotion = true;
                CharacterStateController.Animator.SetTrigger(isBottom ? bottomUpParameter : topDownParameter);

                state = LadderClimbState.AnimationBased;

                break;

            case LadderClimbState.AnimationBased:

                if (CharacterStateController.Animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
                {
                    if (CharacterActions.interact.Started)
                    {
                        forceExit = true;
                    }
                    else
                    {
                        if (CharacterActions.movement.Up)
                        {
                            if (currentClimbingAnimation == currentLadder.ClimbingAnimations)
                            {
                                CharacterStateController.Animator.SetTrigger(topUpParameter);
                            }
                            else
                            {
                                CharacterStateController.Animator.SetTrigger(upParameter);
                                currentClimbingAnimation++;
                            }
                        }
                        else if (CharacterActions.movement.Down)
                        {
                            if (currentClimbingAnimation == 0)
                            {
                                CharacterStateController.Animator.SetTrigger(bottomDownParameter);
                            }
                            else
                            {
                                CharacterStateController.Animator.SetTrigger(downParameter);
                                currentClimbingAnimation--;
                            }
                        }
                    }
                }
                else if (CharacterStateController.Animator.GetCurrentAnimatorStateInfo(0).IsName("Entry"))
                {
                    forceExit = true;
                    CharacterActor.ForceGrounded();
                }

                break;
            }
        }
Beispiel #9
0
 public override void DoExit(CharacterActor characterActor)
 {
     Time.timeScale = 1f;
     characterActor.thisCollisionCollider2D.offset   = boxColliderInfo.offset;
     characterActor.thisCollisionCollider2D.size     = boxColliderInfo.size;
     characterActor.thisInteractionCollider2D.offset = boxColliderInfo.offset;
     characterActor.thisInteractionCollider2D.size   = boxColliderInfo.size;
 }
Beispiel #10
0
            public override void DoEnter(CharacterActor characterActor)
            {
                timer = 0f;

                characterActor.thisAnimator.PlayNoRepeat("Jump");
                characterActor.thisCharacter2D.thisRigidbody2D.velocity = new Vector2(characterActor.thisCharacter2D.thisRigidbody2D.velocity.x, 0f);
                Singleton.Get <IAudioController>().PlayOneShot(stepSound);
            }
Beispiel #11
0
 // Start is called before the first frame update
 void Start()
 {
     if (player == null)
     {
         player = PlayerController.Instance.Actor;
     }
     StartCoroutine(Play());
 }
Beispiel #12
0
        protected virtual void Awake()
        {
            characterActor = this.GetComponentInBranch <CharacterActor>();

            characterActions.InitializeActions();

            inputHandlerSettings.Initialize(gameObject);
        }
Beispiel #13
0
            public override void DoEnter(CharacterActor characterActor)
            {
                characterActor.thisAnimator.PlayNoRepeat("Duck");

                characterActor.thisCollisionCollider2D.offset = boxColliderInfo.offset;
                characterActor.thisCollisionCollider2D.size   = boxColliderInfo.size;

                characterActor.thisInteractionCollider2D.offset = boxColliderInfo.offset;
                characterActor.thisInteractionCollider2D.size   = boxColliderInfo.size;
            }
Beispiel #14
0
        void Awake()
        {
            instance = this;
            actor    = GetComponent <CharacterActor>();
            var p = GetComponent <DialogPartner>();

            p.displayName = System.Environment.UserName;

            actor.onKilledBy += OnActorDeath;
        }
Beispiel #15
0
 public override void DoUpdate(CharacterActor characterActor)
 {
     if (characterActor.thisAnimator.GetCurrentAnimatorStateInfo(0).IsName("Transition"))
     {
         if (characterActor.thisAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime > .95f)
         {
             characterActor.movementStateMachine.PopState();
         }
     }
 }
Beispiel #16
0
            public override void DoEnter(CharacterActor characterActor)
            {
                characterActor.thisAnimator.runtimeAnimatorController = runtimeAnimatorController;

                characterActor.transitionMovementState.transitionSound = transitionSound;
                characterActor.transitionMovementState.boxColliderInfo = transitionBoxColliderInfo;

                characterActor.duckMovementState.boxColliderInfo = duckBoxColliderInfo;

                characterActor.jumpMovementState.jumpSound = jumpSound;
            }
Beispiel #17
0
        public override void EnterBehaviour(float dt, CharacterState fromState)
        {
            CharacterActor.Velocity *= initialIntertia;
            CharacterActor.Forward   = -CharacterActor.WallContact.normal;

            if (modifySize)
            {
                initialSize = CharacterActor.BodySize;
                CharacterActor.SetBodySize(new Vector2(width, height));
            }
        }
Beispiel #18
0
 public override void DoCharacter2DCasterHit(CharacterActor characterActor, Direction direction, RaycastHit2D hit, Collider2D collider)
 {
     switch (direction)
     {
     case Direction.Up:
         // Fall if we bump on something above
         if (Mathf.Abs(characterActor.transform.position.x - collider.transform.position.x) < .7f)
         {
             characterActor.movementStateMachine.SetState(characterActor.fallMovementState);
         }
         break;
     }
 }
Beispiel #19
0
        void Start()
        {
            characterActor = this.GetComponentInBranch <CharacterActor>();

            if (characterActor == null)
            {
                this.enabled = false;
                return;
            }

            SetCurrentSurface(materialsProperties.DefaultSurface);
            SetCurrentVolume(materialsProperties.DefaultVolume);
        }
Beispiel #20
0
        public override void ExitBehaviour(float dt, CharacterState toState)
        {
            if (wallJump)
            {
                wallJump = false;

                CharacterActor.Velocity = jumpVerticalVelocity * CharacterActor.Up + jumpNormalVelocity * CharacterActor.WallContact.normal;
            }

            if (modifySize)
            {
                CharacterActor.SetBodySize(initialSize);
            }
        }
Beispiel #21
0
            public override void DoFixedUpdate(CharacterActor characterActor)
            {
                if (timer > bounceTime)
                {
                    characterActor.movementStateMachine.PopState();
                }
                else
                {
                    timer += Time.fixedDeltaTime;

                    float speed = characterActor.isSprinting ? characterActor.airSprintSpeed : characterActor.airMoveSpeed;
                    characterActor.thisCharacter2D.Move(new Vector2(characterActor.inputAxis.x * speed, 1f * characterActor.jumpSpeed) * Time.fixedDeltaTime);
                }
            }
Beispiel #22
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (!isReady)
            {
                return;
            }

            CharacterActor characterActor = GetCharacter(other.transform);

            if (characterActor != null)
            {
                ChangeGravitySettings(characterActor);
                characterActor.Up = reference.referenceTransform.up;
            }
        }
Beispiel #23
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (!isReady)
            {
                return;
            }

            CharacterActor characterActor = GetCharacter(other.transform);

            if (characterActor != null)
            {
                HandleUpDirection(characterActor);
                characterActor.Up = reference.referenceTransform.up;
            }
        }
        private CharacterActor actorFromRow(HtmlNode node)
        {
            var            actorElement = node.SelectSingleNode("./td/a");
            CharacterActor ca           = new CharacterActor();
            VoiceActor     actor        = new VoiceActor();

            actor.Name = new Name()
            {
                English = commaDelimitedName(actorElement.InnerHtml)
            };
            actor.VoiceActorID = parseLinkId(actorElement.GetAttributeValue("href", ""));
            ca.Actor           = actor;
            ca.ActorId         = actor.VoiceActorID;
            ca.Language        = new Language(node.SelectSingleNode("./td/small").InnerHtml);
            return(ca);
        }
        public void TestReadValidCharacterActors()
        {
            int characterId = 227;
            int actorId     = 85;
            ICollection <Character> result = mParser.Parse(mAnimeHtml);

            IEnumerable <CharacterActor> characterActors = result.Where(r => r.CharacterID == characterId).SingleOrDefault().Actors;

            Assert.AreEqual(5, characterActors.Count());
            Assert.True(characterActors.Select(ca => ca.Actor.VoiceActorID).Contains(actorId));

            CharacterActor characterActor = characterActors.Where(ca => ca.Actor.VoiceActorID == actorId).SingleOrDefault();

            Assert.AreEqual("Michelle Ruff", characterActor.Actor.Name.English);
            Assert.AreEqual("English", characterActor.Language.ToString());
        }
Beispiel #26
0
    void SelectTarget(CharacterActor selected)
    {
        if (targeting = true && targetChecker != null && targetChecker(selected.Owner))
        {
            selectedChars.Add(selected.Owner);
            if (selectedChars.Count >= numOfTargetsSelecting)
            {
                onComplete.Invoke(selectedChars);

                selectedChars.Clear();
                onComplete            = null;
                onCancel              = null;
                targetChecker         = null;
                numOfTargetsSelecting = 0;
                Targeting             = false;
            }
        }
    }
Beispiel #27
0
        // Vector3 FinalTargetPosition => target.position + transform.TransformVector( offset );
        void Start()
        {
            if (target == null)
            {
                Debug.Log("Missing camera target");
            }


            characterActor = target.GetComponent <CharacterActor>();

            // transform.position = FinalTargetPosition;

            targetBounds        = new Bounds(target.position, new Vector3(targetAABBSize.x, targetAABBSize.y, 1f));
            targetBounds.center = target.position;

            cameraAABB = new Bounds(target.position, new Vector3(cameraAABBSize.x, cameraAABBSize.y, 1f));

            targetCameraPosition = new Vector3(cameraAABB.center.x, cameraAABB.center.y, transform.position.z);
        }
Beispiel #28
0
        void AddAndInitializeStates()
        {
            CharacterState[] statesArray = CharacterActor.GetComponentsInChildren <CharacterState>();
            for (int i = 0; i < statesArray.Length; i++)
            {
                CharacterState state     = statesArray[i];
                string         stateName = state.GetType().Name;

                // The state is already included, ignore it!
                if (GetState(stateName) != null)
                {
                    Debug.Log("Warning: GameObject " + state.gameObject.name + " has the state " + stateName + " repeated in the hierarchy.");
                    continue;
                }

                states.Add(stateName, state);
                // state.Initialize();
            }
        }
Beispiel #29
0
        void OnAnimatorMoveEvent(Vector3 deltaPosition, Quaternion deltaRotation)
        {
            if (!UseRootMotion)
            {
                return;
            }


            if (CharacterActor.IsKinematic)
            {
                CharacterActor.Position += deltaPosition;
                CharacterActor.Rotation *= deltaRotation;
            }
            else
            {
                CharacterActor.Move(CharacterActor.Position + deltaPosition);
                CharacterActor.Rotate(CharacterActor.Rotation * deltaRotation);
            }
        }
Beispiel #30
0
        void Awake()
        {
            CharacterActor = this.GetComponentInBranch <CharacterActor>();


            materialController = this.GetComponentInBranch <CharacterActor, MaterialController>();

            if (materialController == null)
            {
                Debug.Log("CharacterMaterial component missing");
                this.enabled = false;
            }



            if (groundParticlesPrefab != null)
            {
                particlesPooler = new ParticleSystemPooler(groundParticlesPrefab, CharacterActor.transform.position, CharacterActor.transform.rotation, 10);
            }
        }