void Start() { gameMarker = GameObject.Find("Game Root/GameMarker"); currentStunDuration = maxStunDuration; myRigidbody = GetComponent <Rigidbody2D>(); players.Add(gameObject); playerHitState = gameObject.AddComponent <PlayerHitState>() as PlayerHitState; playerHitState.player = gameObject; GameObject vulcanObject = Instantiate(Resources.Load("Vulcan"), transform.position, Quaternion.identity) as GameObject; vulcanObject.transform.parent = transform; vulcan = vulcanObject.GetComponent <Vulcan>() as Vulcan; vulcan.player = this; GameObject bombLauncherObject = Instantiate(Resources.Load("Bomb Launcher"), transform.position, Quaternion.identity) as GameObject; bombLauncherObject.transform.parent = transform; bombLauncher = bombLauncherObject.GetComponent <BombLauncher>() as BombLauncher; bombLauncher.player = this; shotgun = gameObject.AddComponent <Shotgun>() as Shotgun; shotgun.player = this; gigaBeam = gameObject.AddComponent <GigaBeam>() as GigaBeam; gigaBeam.player = this; magnetMissile = gameObject.AddComponent <MagnetMissile>() as MagnetMissile; magnetMissile.player = this; reversePosition = GetComponent <Entity>().affinity.GetComponent <Fleet>().reversePosition; body = transform.Find("Body").gameObject; body.GetComponent <SpriteRenderer>().color = GetComponent <Entity>().affinity.GetComponent <Fleet>().teamColor; shieldObject = Instantiate(shieldPrefab, transform.position, Quaternion.identity) as GameObject; shieldObject.transform.parent = gameObject.transform; shield = shieldObject.GetComponent <Shield>(); shield.player = this; playerHitState.SwitchToInvincible(); damageBehavior = GetComponent <DamageBehavior>(); currentExValue = GetComponent <Entity>().affinity.GetComponent <Fleet>().lastExValue; gameObject.transform.eulerAngles = new Vector3( gameObject.transform.eulerAngles.x, gameObject.transform.eulerAngles.y, gameObject.transform.eulerAngles.z - 90); vehicleControls = GetComponent <VehicleControls>(); if (reversePosition) { reverseIndex *= -1; } GameObject playerHud = Instantiate(Resources.Load("HUD/PlayerHUD"), transform.position, Quaternion.identity) as GameObject; playerHud.transform.parent = GameObject.Find("WorldspaceHUD").transform; playerHud.GetComponent <PlayerHUD>().player = this; defaultColor = body.GetComponent <SpriteRenderer>().color; foreach (Transform child in body.transform) { CarWheel wheel = child.GetComponent <CarWheel>(); if (wheel) { wheel.vehicleControls = vehicleControls; } } currentExValue = maxExValue; }
override protected void InitState() { base.InitState(); State attackState = new PlayerAttackState(); attackState.Init(this); _stateDic[eSTATE.ATTACK] = attackState; State moveState = new MoveState(); moveState.Init(this); _stateDic[eSTATE.MOVE] = moveState; State hitState = new PlayerHitState(); hitState.Init(this); _stateDic[eSTATE.HIT] = hitState; State skillOneState = new SkillOne(); skillOneState.Init(this); _stateDic[eSTATE.HIT] = skillOneState; State skillTwoState = new SkillTwo(); skillTwoState.Init(this); _stateDic[eSTATE.HIT] = skillTwoState; State skillThreeState = new SkillThree(); skillThreeState.Init(this); _stateDic[eSTATE.HIT] = skillThreeState; State idleState = new PlayerIdleState(); idleState.Init(this); _stateDic[eSTATE.IDLE] = idleState; }
void Start() { gameMarker = GameObject.Find("Game Root/GameMarker"); currentStunDuration = maxStunDuration; myRigidbody = GetComponent<Rigidbody2D>(); players.Add (gameObject); playerHitState = gameObject.AddComponent<PlayerHitState>() as PlayerHitState; playerHitState.player = gameObject; GameObject vulcanObject = Instantiate (Resources.Load ("Vulcan"), transform.position, Quaternion.identity) as GameObject; vulcanObject.transform.parent = transform; vulcan = vulcanObject.GetComponent<Vulcan>() as Vulcan; vulcan.player = this; GameObject bombLauncherObject = Instantiate (Resources.Load ("Bomb Launcher"), transform.position, Quaternion.identity) as GameObject; bombLauncherObject.transform.parent = transform; bombLauncher = bombLauncherObject.GetComponent<BombLauncher>() as BombLauncher; bombLauncher.player = this; shotgun = gameObject.AddComponent<Shotgun>() as Shotgun; shotgun.player = this; gigaBeam = gameObject.AddComponent<GigaBeam>() as GigaBeam; gigaBeam.player = this; magnetMissile = gameObject.AddComponent<MagnetMissile>() as MagnetMissile; magnetMissile.player = this; reversePosition = GetComponent<Entity>().affinity.GetComponent<Fleet>().reversePosition; body = transform.Find ("Body").gameObject; body.GetComponent<SpriteRenderer>().color = GetComponent<Entity>().affinity.GetComponent<Fleet>().teamColor; shieldObject = Instantiate (shieldPrefab, transform.position, Quaternion.identity) as GameObject; shieldObject.transform.parent = gameObject.transform; shield = shieldObject.GetComponent<Shield>(); shield.player = this; playerHitState.SwitchToInvincible(); damageBehavior = GetComponent<DamageBehavior>(); currentExValue = GetComponent<Entity>().affinity.GetComponent<Fleet>().lastExValue; gameObject.transform.eulerAngles = new Vector3( gameObject.transform.eulerAngles.x, gameObject.transform.eulerAngles.y, gameObject.transform.eulerAngles.z - 90); vehicleControls = GetComponent<VehicleControls>(); if(reversePosition) reverseIndex *= -1; GameObject playerHud = Instantiate (Resources.Load ("HUD/PlayerHUD"), transform.position, Quaternion.identity) as GameObject; playerHud.transform.parent = GameObject.Find ("WorldspaceHUD").transform; playerHud.GetComponent<PlayerHUD>().player = this; defaultColor = body.GetComponent<SpriteRenderer>().color; foreach(Transform child in body.transform){ CarWheel wheel = child.GetComponent<CarWheel>(); if(wheel){ wheel.vehicleControls = vehicleControls; } } currentExValue = maxExValue; }