Ejemplo n.º 1
0
 void Awake()
 {
     controller     = GetComponent <IController2D>();
     stateMachine   = GetComponent <ITerrainState>();
     attack         = GetComponent <IAttack>();
     lockedShooting = false;
 }
Ejemplo n.º 2
0
        public void Awake()
        {
            charFactory = GetComponent <PlayableCharacterFactory>();
            //Create the character.
            _myCharacter = charFactory.CreateCharacter(AvailableCharacters.Ruyo);
            //Assign freshly created character as child of this gameobject.
            _myCharacter.CharacterInstance.transform.parent = transform;
            //Make sure that the created character is positioned in the middle of the player gameobject.
            _myCharacter.CharacterInstance.transform.localPosition = Vector3.zero;
            //Get the launcher from the character and store its script ref...
            _launcher = _myCharacter.CharacterInstance.GetComponentInChildren <ILauncher>();
            //...same with the crosshair + setup the camera script.
            _crosshair = _myCharacter.CharacterInstance.GetComponentInChildren <Crosshair>();
            _crosshair.Begin(_cameraWorks);
            _controller2D = _myCharacter.CharacterInstance.GetComponentInChildren <IController2D>();
            //Get the healthbar script for the character, if it has any healthbar.
            _myCharacter.AddHealthBarReference(GetComponentInChildren <RuyoHealthbar>());

            _skillManager.AddObserver(_crosshair);
            //Create the skills factory. Then retrieve the factory script and proper skill factory.
            GameObject factorySelector = Instantiate(_factorySelectorPrefab);

            factorySelector.transform.parent = this.gameObject.transform;
            _skillFactorySelector            = factorySelector.GetComponent <ISkillFactorySelector>();
            ISkillFactory skillFactory = _skillFactorySelector.SelectFactory(AvailableCharacters.Ruyo);
            //Using the provided skill factory, generate the skills for the character.
            IGetTransform playerTransform      = this;
            IGetTransform shotSpawnerTransform = _launcher;
            //Create and assign the skills to the skills manager and save them temporarily for the
            //skillBarManager.
            IDictionary <SkillType, Sprite> skillsIcons = new Dictionary <SkillType, Sprite>();
            //Basic skill:
            ISkill newSkill = skillFactory.CreateSkill(SkillType.Basic, ref shotSpawnerTransform, ref playerTransform);

            newSkill.GameObject.transform.parent = this.gameObject.transform;
            _skillManager.AddSkill(SkillType.Basic, newSkill);
            //First active skill:
            newSkill = skillFactory.CreateSkill(SkillType.First, ref shotSpawnerTransform, ref playerTransform);
            newSkill.GameObject.transform.parent = this.gameObject.transform;
            _skillManager.AddSkill(SkillType.First, newSkill);
            skillsIcons.Add(SkillType.First, newSkill.icon);
            //Second active skill:
            newSkill = skillFactory.CreateSkill(SkillType.Second, ref shotSpawnerTransform, ref playerTransform);
            newSkill.GameObject.transform.parent = this.gameObject.transform;
            _skillManager.AddSkill(SkillType.Second, newSkill);
            skillsIcons.Add(SkillType.Second, newSkill.icon);
            //Third active skill:
            newSkill = skillFactory.CreateSkill(SkillType.Third, ref shotSpawnerTransform, ref playerTransform);
            newSkill.GameObject.transform.parent = this.gameObject.transform;
            _skillManager.AddSkill(SkillType.Third, newSkill);
            skillsIcons.Add(SkillType.Third, newSkill.icon);

            //Initialize the skillBarManager skill icons.
            SkillsBarManager skillBarManager = _myCharacter.CharacterInstance.GetComponentInChildren <SkillsBarManager>();

            skillBarManager.InitializeSkillsIcons(skillsIcons);
            _skillManager.AddObserver(skillBarManager);
        }
Ejemplo n.º 3
0
 void Awake()
 {
     controller     = GetComponent <IController2D>();
     stateMachine   = GetComponent <ITerrainState>();
     attack         = GetComponent <IAttack>();
     dash           = GetComponent <IDash>();
     jump           = GetComponent <IJump>();
     move           = GetComponent <IMovement>();
     timeControll   = GetComponent <ITimeControll>();
     lockedShooting = false;
 }
Ejemplo n.º 4
0
 void Awake()
 {
     controller   = GetComponent <IController2D>();
     stateMachine = GetComponent <ITerrainState>();
     dash         = GetComponent <IDash>();
 }
Ejemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     _controller = GetComponent <Controller2D>();
     SetJumpValues();
 }
Ejemplo n.º 6
0
 void Awake()
 {
     controller   = GetComponent <IController2D>();
     stateMachine = GetComponent <ITerrainState>();
     jump         = GetComponent <IJump>();
 }
Ejemplo n.º 7
0
 void Awake()
 {
     controller   = GetComponent <IController2D>();
     timeControll = GetComponent <ITimeControll>();
 }
Ejemplo n.º 8
0
 void Awake()
 {
     controller   = GetComponent <IController2D>();
     stateMachine = GetComponent <ITerrainState>();
     move         = GetComponent <IMovement>();
 }