private void ActivateItem() { if (PlayerStatus.Incapacitated || !inventoryUI.gameObject.activeInHierarchy) return; ActiveItem toActivate = null; if (Input.GetKeyDown(KeyCode.Alpha1)) toActivate = items[0] as ActiveItem; if (Input.GetKeyDown(KeyCode.Alpha2)) toActivate = items[1] as ActiveItem; if (Input.GetKeyDown(KeyCode.Alpha3)) toActivate = items[2] as ActiveItem; if (Input.GetKeyDown(KeyCode.Alpha4)) toActivate = items[3] as ActiveItem; toActivate?.Activate(); }
public void ActivateItem(object item) { ActiveItem = item as IScreen; var child = ActiveItem as IChild; if (child != null) { child.Parent = this; } if (ActiveItem != null) { ActiveItem.Activate(); } NotifyOfPropertyChange(() => ActiveItem); OnActivationProcessed(ActiveItem, true); }
public void ActivateItem(object item) { ActiveItem = item as IScreen; var child = ActiveItem as IChild; if (child != null) { child.Parent = this; } if (ActiveItem != null) { ActiveItem.Activate(); } NotifyOfPropertyChange(() => ActiveItem); ActivationProcessed(this, new ActivationProcessedEventArgs { Item = ActiveItem, Success = true }); }
private void ActivateCurrentItem(IScreen screen) { ActivateItem(screen); ActiveItem.Activate(); }
protected virtual void Update() { if (PausePressed()) { GameManager.o.pause = !GameManager.o.pause; } if (GameManager.o.pause) { return; } if (!defeated) { if (invincible) { invincibleTime -= Time.deltaTime; if (invincibleTime <= 0) { invincible = false; } } if (currentMagic < maxMagic) { magicRechargeCurrent -= Time.deltaTime; if (magicRechargeCurrent <= 0) { currentMagic += 1; if (currentMagic == maxMagic) { magicRechargeCurrent = magicRecharge; } else { magicRechargeCurrent += magicRecharge; } } } if (basicCooldownCurrent > 0) { basicCooldownCurrent -= Time.deltaTime; } if (specialCooldownCurrent > 0) { specialCooldownCurrent -= Time.deltaTime; } if (active1CooldownCurrent > 0) { active1CooldownCurrent -= Time.deltaTime; } if (active2CooldownCurrent > 0) { active2CooldownCurrent -= Time.deltaTime; } if (wallJump != 0) { if (Time.deltaTime > Mathf.Abs(wallJump)) { wallJump = 0; } else { wallJump -= Time.deltaTime * Mathf.Sign(wallJump); } } grab = false; pickup = false; s = Vector2.zero; if (inputLock) { lockTime -= Time.deltaTime; if (lockTime <= 0) { UnlockInput(); } } else { if (Left()) { s.x = -speed; direction = -1; } else if (Right()) { s.x = speed; direction = 1; } if (Jump()) { if (physics.speed.y >= 0) { s.y = jumpHeight / 1.5f; } else { s.y = jumpHeight / 5; } } if (physics.collideBottom) { extraJumpsCurrent = extraJumps; if (JumpPressed()) { physics.SetSpeedY(jumpHeight, 0.15f); } } else if (physics.collideRight) { if (Right()) { wallJump = 0.1f; if (physics.ledge > 0 && physics.speed.y <= 0) { transform.position = new Vector3(transform.position.x, physics.ledge - transform.localScale.y / 1.5f, transform.position.z); if (JumpPressed()) { physics.SetSpeedY(jumpHeight, 0.15f); wallJump = 0; } else { physics.SetSpeedY(0, 0); } } else if (physics.speed.y <= -physics.gravity / 4) { physics.SetSpeedY(-physics.gravity / 4, 0); } } if (wallJump != 0 && JumpPressed()) { physics.SetSpeedX(-speed, 0.15f); physics.SetSpeedY(jumpHeight, 0.15f); wallJump = 0; } } else if (physics.collideLeft) { if (Left()) { wallJump = -0.1f; if (physics.ledge > 0 && physics.speed.y <= 0) { transform.position = new Vector3(transform.position.x, physics.ledge - transform.localScale.y / 1.5f, transform.position.z); if (JumpPressed()) { physics.SetSpeedY(jumpHeight, 0.15f); wallJump = 0; } else { physics.SetSpeedY(0, 0); } } else if (physics.speed.y <= -physics.gravity / 4) { physics.SetSpeedY(-physics.gravity / 4, 0); } } if (wallJump != 0 && JumpPressed()) { physics.SetSpeedX(speed, 0.15f); physics.SetSpeedY(jumpHeight, 0.15f); wallJump = 0; } } else if (wallJump != 0 && JumpPressed()) { if (wallJump > 0) { physics.SetSpeedX(-speed, 0.15f); physics.SetSpeedY(jumpHeight, 0.15f); } else { physics.SetSpeedX(speed, 0.15f); physics.SetSpeedY(jumpHeight, 0.15f); } wallJump = 0; } else if (extraJumpsCurrent > 0 && JumpPressed()) { extraJumpsCurrent--; physics.SetSpeedY(jumpHeight, 0.15f); } else if (extraJumpsCurrent == 0 && JumpPressed() && inputType == "AI") { //for scoring the AI for mistakes if (ai != null) { ai.score -= 0.25; } } if (AttackPressed()) { AttackEffect(); } else if (SpecialPressed()) { SpecialEffect(); } if (Grab1Pressed() || Grab2Pressed() || Down()) { grab = true; } if (active1 != null && Item1Pressed() && active1CooldownCurrent <= 0 && currentMagic >= active1.cost) { active1CooldownCurrent = active1.cooldown; currentMagic -= active1.cost; active1.Activate(this); } if (active2 != null && Item2Pressed() && active2CooldownCurrent <= 0 && currentMagic >= active2.cost) { active2CooldownCurrent = active2.cooldown; currentMagic -= active2.cost; active2.Activate(this); } } foreach (Item p in passives) { p.Tick(this); } if (active1 != null) { active1.Tick(this); } if (active2 != null) { active2.Tick(this); } } physics.Move(s); prevLeft = Left(); prevRight = Right(); prevUp = Up(); prevDown = Down(); if (inputType != "Keyboard") { prevSpecial = Special(); } if (currentHealth <= 0) { gameObject.layer = 0; defeated = true; physics.collLayer2 = null; animator.state = "defeated"; } }