Exemple #1
0
    // Use this for initialization
    protected void Start()
    {
        gameController = GameController_S.self;

        mainCamera = Camera_S.self.GetComponent <Camera>();

        playerSprite = transform.GetChild(0).gameObject;
        spriteRigid  = playerSprite.GetComponent <Rigidbody>();
        animator     = playerSprite.GetComponent <Animator>();
        rigid        = GetComponent <Rigidbody2D>();

        canvasResources = canvas.GetComponent <Canvas_S>();
        cameraShake     = gameController.gameObject.GetComponent <CameraShake_S>();


        invincibilityFlashTicks = (int)((invincibilitySeconds - 0.28f) / 0.16f);
    }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        playerSprite = transform.parent.GetChild(0).gameObject;

        cameraShake = GameController_S.self.gameObject.GetComponent <CameraShake_S>();
        gunSprite   = transform.GetChild(0).gameObject;
        muzzle      = transform.GetChild(1).gameObject;


        firingSound = GetComponent <AudioSource>();
        gunSprite.GetComponent <SpriteRenderer>().sprite = gun.weapon;                   // Sets Gun Sprite to the Scriptable Object's Sprite

        muzzle.transform.localPosition.Set(gun.muzzleLocationX, gun.muzzleLocationY, 0); // Sets the Muzzle Location

        if (gun.childGameObject != null)                                                 // Tests and Creates Child of Gun
        {
            childSprite = Instantiate(gun.childGameObject, gunSprite.transform);
            gunSprite.GetComponent <GunLayerManagement_S>().setChildSprite(childSprite);
        }

        animator = transform.GetChild(0).GetComponent <Animator>();
        animator.runtimeAnimatorController = gun.animation; // Sets the Animation Controller of the Sprite


        // Sets different aspects of the gun
        firingSound.clip = gun.firingSound;
        fireRate         = gun.fireRate;
        totalBullets     = gun.bulletCount - gun.clipSize;
        clipSize         = gun.clipSize;
        currentBullets   = gun.clipSize;
        reloadSpeed      = gun.reloadSpeed;
        reloadSound      = gun.reloadSound;


        canvasResources = canvas.GetComponent <Canvas_S>(); // Gets Canvas Script of the game;
        gunUIText       = canvasResources.getGunUIText();   // Gets the Gun UI Text from the Canvas Script;
        gunUIText.color = Color.blue;
        gunUIText.text  = "staples x " + currentBullets;
    }