void ChangeRobot(int newRobotID) { Robot previousRobot = currentRobot; robots.TryGetValue(newRobotID, out currentRobot); if (currentRobot == null) { currentRobot = previousRobot; Debug.LogError("currentRobot == null in Player"); return; } // Cancel all activivties for previous robot and set unactive status previousRobot.CancelExtraSkill(); previousRobot.gameObject.SetActive(false); SetAnimatorToRobot(currentRobot); // Change robot to new one animationRenderer.SetInteger("RobotID", currentRobot.robotID); TriggerChangeRobot(previousRobot.robotID, newRobotID); currentRobot.gameObject.SetActive(true); }
void ChangeRobot(int newRobotId) { var previousRobot = _currentRobot; _robots.TryGetValue(newRobotId, out _currentRobot); if (_currentRobot == null) { _currentRobot = previousRobot; Debug.LogError("currentRobot == null in Player"); return; } // Cancel all activivties for previous robot and set unactive status previousRobot.CancelExtraSkill(); previousRobot.gameObject.SetActive(false); _currentRobot.gameObject.SetActive(true); // Change robot to new one animationRenderer.SetInteger("RobotID", _currentRobot.robotID); TriggerChangeRobot(previousRobot.robotID, newRobotId); _groundChecker.SetGroundCheck(_currentRobot.GroundCheck); }