void Awake() { MaxHealth = 150; Health = 150; PlayerOnephysics = GetComponent <PlayerPhysics>(); StateController = GetComponent <StateController>(); LiteHit = 5; MediumHit = 10; HeavyHit = 20; }
public void Start() { var imgs = GetComponentsInChildren <Image>(); foreach (Image image in imgs) { if (image.name.Contains("Area")) { areaGravityRose = image.gameObject; } else if (image.name.Contains("Player")) { playerGravityRose = image.gameObject; } else { Debug.LogError(image.name + " is not a valid Gravity Indicator Image"); } } var tmps = GetComponentsInChildren <TextMeshProUGUI>(); foreach (TextMeshProUGUI tmp in tmps) { if (tmp.name.Contains("Area")) { areaMagnitudeTMP = tmp; } else if (tmp.name.Contains("Player")) { playerMagnitudeTMP = tmp; } else { Debug.LogError(tmp.name + " is not a valid Gravity Indicator TMP"); } } playerPhysics = GameObject.FindGameObjectWithTag(Tags.PLAYER).GetComponent <IActorPhysics>(); }
void Awake() { // Gets the PlayerPhysics component playerPhysics = GetComponent <IActorPhysics>(); // Gets the WeaponManager component weaponManager = GetComponent <WeaponManager> (); // Gets the animator component animator = GetComponent <Animator>(); // Check if the Character Controller was found if (playerPhysics == null) { Debug.LogError("IActorPhysics component not found."); } // Check if the Character Controller was found if (weaponManager == null) { //Debug.LogError("IWeaponManager component not found."); } // Check if the animator component was found if (animator == null) { Debug.LogError("Animator component not found"); } // Stores the scale of the player xScale = transform.localScale.x; // TODO Change this - Not working properly //child = transform.FindChild("Zuckov"); //xScale = child.localScale.x; }
public void Awake() { sprite = GetComponent <SpriteRenderer>(); actorPhysics = GetComponent <IActorPhysics>(); if (!animator) { animator = GetComponent <Animator>(); if (!animator) { Debug.LogWarning("No animator found for " + gameObject.name); } } actionStateLookup = new Dictionary <ActionStateType, IActionState>(); movementStateLookup = new Dictionary <MovementStateType, IMovementState>(); if (!standingState) { standingState = GetComponentInChildren <StandingState>(); } if (standingState) { standingState.SetActor(this); movementStateLookup.Add(MovementStateType.STANDING, standingState); } if (!duckingState) { duckingState = GetComponentInChildren <KneelingState>(); } if (duckingState) { duckingState.SetActor(this); movementStateLookup.Add(MovementStateType.KNEELING, duckingState); } if (!walkingState) { walkingState = GetComponentInChildren <WalkingState>(); } if (walkingState) { walkingState.SetActor(this); movementStateLookup.Add(MovementStateType.WALKING, walkingState); } if (stairsState) { stairsState.SetActor(this); movementStateLookup.Add(MovementStateType.STAIRS, stairsState); } if (!airbornState) { airbornState = GetComponentInChildren <FallingState>(); } if (airbornState) { airbornState.SetActor(this); movementStateLookup.Add(MovementStateType.FALLING, airbornState); } if (!jetpackState) { jetpackState = GetComponentInChildren <JetpackState>(); } if (jetpackState) { jetpackState.SetActor(this); movementStateLookup.Add(MovementStateType.JETPACK, jetpackState); } elevatorState = GetComponentInChildren <ElevatorState>(); if (elevatorState) { elevatorState.SetActor(this); movementStateLookup.Add(MovementStateType.ELEVATOR, elevatorState); actionStateLookup.Add(ActionStateType.ELEVATOR, elevatorState); } NoActionState awaitingState = new NoActionState(); awaitingState.SetActor(this); actionStateLookup.Add(ActionStateType.AWAITING_ACTION, awaitingState); if (!shootingState) { shootingState = GetComponentInChildren <ShootingState>(); } if (shootingState) { shootingState.SetActor(this); actionStateLookup.Add(ActionStateType.SHOOT, shootingState); } currentMovementState = MovementStateType.FALLING; movementState = airbornState; currentActionState = ActionStateType.AWAITING_ACTION; actionState = actionStateLookup[ActionStateType.AWAITING_ACTION]; }