// Start is called before the first frame update void Start() { _attacksContainer = GameObject.Find("AttacksContainer"); _characterAnimator = this.GetComponent <Animator>(); _characterAnimator.SetFloat(AnimatorParameter.SLASH_SPEED, _slashAnimationSpeed); _movementController2D = this.GetComponent <MovementController2D>(); }
// Use this for initialization void Start() { Light2D torch = GameObject.Find("Torch").GetComponent <Light2D>(); if (torch == null) { throw new ArgumentNullException("Torch is not attached to player!"); } _animator = GetComponent <Animator>(); if (_animator == null) { throw new ArgumentNullException("Animator is not associated with player!"); } _sanityManager = GetComponent <SanityManager>(); if (_sanityManager == null) { throw new ArgumentNullException("Sanity manager is not associated with player!"); } _controller2D = GetComponent <MovementController2D>(); if (_controller2D == null) { throw new ArgumentNullException("Controller 2D is not associated with player!"); } _attackController = GetComponent <AttackController>(); if (_attackController == null) { throw new ArgumentNullException("Attack controller is not associated with player!"); } _instrumentDisabled = SharedInfo.LostInstrument; _torchDisabled = SharedInfo.LostTorch; _torch = torch; DeactivateTorch(); }
new void Start() { _controller = GetComponent <MovementController2D> (); box = GetComponent <BoxCollider2D>(); dc = GetComponentInChildren <PlayerDamageCollider> (true); _chargeBar = GameObject.Find("InGameUI").GetComponentInChildren <ChargeBarScript>(); Debug.Log("******** NEW PLAYER - HAVE INSTANCE? " + GlobalControl.instance); if (GlobalControl.instance) { Debug.Log("******** YES! " + GlobalControl.instance.playerCP); _chargeBar.chargePercentage = GlobalControl.instance.playerCP; if (GlobalControl.instance.playerHP > 0) { playerHealth = GlobalControl.instance.playerHP; } else { playerHealth = 100; } GlobalControl.instance.resetPlayerStats(); } else { _chargeBar.chargePercentage = 0; playerHealth = 100; } _anim = GetComponent <Animator> (); PlayerAbstractBehaviour[] pabs = _anim.GetBehaviours <PlayerAbstractBehaviour> (); for (var i = pabs.Length - 1; i >= 0; i--) { pabs [i].player = this; } facingLeft = false; facingRight = true; dc.gameObject.SetActive(false); if (stunIcon != null) { stunIcon.SetActive(false); } setState(PlayerStates.mobile); }
// Use this for initialization void Start() { _sanityManager = GetComponent <SanityManager>(); if (_sanityManager == null) { throw new ArgumentNullException("Sanity manager is not associated with player!"); } _movementController2D = GetComponent <MovementController2D>(); if (_movementController2D == null) { throw new ArgumentNullException("Controller 2D is not associated with player!"); } _attackController = GetComponent <AttackController>(); if (_attackController == null) { throw new ArgumentNullException("Attack controller is not associated with player!"); } _itemsController = GetComponent <ItemsController>(); if (_itemsController == null) { throw new ArgumentNullException("Items controller is not associated with player!"); } }
// Use this for initialization protected virtual void Start() { controllerActive = true; moveStateStack = new Stack<MovementState>(3); // Just some initialization and warnings movementComponent = GetComponent<MovementController2D>(); if(movementComponent == null) { Debug.LogWarning("MechController: <" + name + "> Does not have a CharacterController2D component, movement will not work!"); } if(headTransform == null) { Debug.LogWarning("MechController: <" + name + "> Head Transform is not set!"); } // Init the different move states moveState_Normal = new MoveState_Normal(this); // Default to the normal move state currentMoveState = moveState_Normal; moveStateStack.Push(moveState_Normal); // register to listen for damage events mechComponent.damageHandlerCallback = OnDamageHandler; }