void Awake()
        {
            PV                = GetComponent <PhotonView>();
            proxy             = GetComponent <CharacterProxy>();
            movement          = GetComponent <CharacterMovement>();
            fire              = GetComponent <CharacterFire>();
            damage            = GetComponent <CharacterDamage>();
            boosterController = GetComponent <BoosterController>();
            weaponController  = GetComponent <WeaponController>();
            rigidBody         = GetComponent <Rigidbody2D>();
            collider2d        = GetComponent <Collider2D>();

            if (PV.IsMine)
            {
                InitLocal();
            }
            else
            {
                InitProxy();
            }

            PlayerName.Value = PV.Owner.NickName;
            NameChangeEvent.Raise();

            isAlreadyDead = false;
        }
        void InitProxy()
        {
            Destroy(movement); movement = null;
            Destroy(fire); fire         = null;
            Destroy(damage); damage     = null;
            Destroy(boosterController); boosterController = null;
            Destroy(rigidBody); rigidBody   = null;
            Destroy(collider2d); collider2d = null;

            // Replace PlayerName
            PlayerName = ScriptableObject.CreateInstance <StringVariable>();
            GetComponentInChildren <TextReplacer>().Variable = PlayerName;

            // Replace IsDead
            proxy.IsDead    = ScriptableObject.CreateInstance <BoolVariable>();
            IsDead.Variable = proxy.IsDead;

            // Replace WalkSpeed
            movement.WalkSpeed          = ScriptableObject.CreateInstance <FloatVariable>();
            boosterController.WalkSpeed = movement.WalkSpeed;

            // Replace Dash Rate
            movement.DashRate          = ScriptableObject.CreateInstance <FloatVariable>();
            boosterController.DashRate = movement.DashRate;

            // Replace FireRate
            weaponController.FireRate = ScriptableObject.CreateInstance <FloatVariable>();
            fire.FireRate.Variable    = weaponController.FireRate;
        }
Beispiel #3
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            PlayerCharacter player = other.GetComponent <PlayerCharacter>();

            if (player != null)
            {
                BoosterController boosterController = other.GetComponent <BoosterController>();
                if (boosterController != null)
                {
                    boosterController.Add(booster);
                }
                DestroySelf();
            }
        }
Beispiel #4
0
 void Start()
 {
     proxy             = GetComponent <CharacterProxy>();
     boosterController = GetComponent <BoosterController>();
 }