Exemplo n.º 1
0
    private void Start()
    {
        //this is just to find the bottom of the object


        var capColl = gameObject.GetComponentInChildren <CapsuleCollider>();

        if (capColl != null)
        {
            rayOffset = (capColl.height / 2f) * capColl.gameObject.transform.localScale.y;
        }
        else
        {
            rayOffset = 1f; Debug.Log("couldn't find capsule collider"); Debug.Log(gameObject.name);
        }

        var canvas = gameObject.GetComponentInChildren <Canvas>();

        if (canvas != null)
        {
            note = canvas.gameObject;
        }
        else
        {
            Debug.Log("can't find canvas gameObject for draggable"); note = null;
        }

        player = FindObjectOfType <KE_MainPlayer_Script>();
        if (player == null)
        {
            Debug.Log("can't find player");
        }
    }
Exemplo n.º 2
0
    protected override void Start()
    {
        turretRange                = (turretRange > 0f) ? turretRange : 40f;
        turretBaseRotationSpeed    = (turretBaseRotationSpeed > 0f) ? turretBaseRotationSpeed : 120f;
        turretCurrentRotationSpeed = turretBaseRotationSpeed;
        shotBaseTimerMax           = (shotBaseTimerMax > 0f) ? shotBaseTimerMax : .4f;
        shotCurrentTimerMax        = shotBaseTimerMax;

        bulletSpeed  = (bulletSpeed > 0f) ? bulletSpeed : 18f;
        bulletTimer  = (bulletTimer > 0f) ? bulletTimer : 3f;
        bulletDamage = (bulletDamage > 0) ? bulletDamage : 15;


        base.Start();
        mainPlayerScript = FindObjectOfType <KE_MainPlayer_Script>(); //assigns the variable so that upgrades can happen
        lastUpgradeLevel = mainPlayerScript.passiveUpgradeLevels[1];
    }
Exemplo n.º 3
0
    public PlayerData(KE_MainPlayer_Script player)
    {
        health       = player.GetComponent <AMS_Health_Management>().currentHealth;
        ammoClips1   = player.GetComponent <AMS_GunManagement>().currentClips;
        ammoClips2   = player.GetComponent <AMS_GunManagement>().gun2currentClips;
        ammo1        = player.GetComponent <AMS_GunManagement>().currentAmmo;
        ammo2        = player.GetComponent <AMS_GunManagement>().gun2currentAmmo;
        unlocked     = player.GetComponent <AMS_GunManagement>().unlocked;
        currentLevel = player.GetComponent <MainMenu>().levelIndex;
        altFireammo  = player.GetComponent <AMS_GunManagement>().defaultAlternateFireAmmo;
        currentGun   = player.GetComponent <AMS_GunManagement>().currentGun;
        var chSpawn = StaticCheckpointController.WhereToSpawn();

        spawn[0] = (int)chSpawn.x;
        spawn[1] = (int)chSpawn.y;
        spawn[2] = (int)chSpawn.z;
    }
Exemplo n.º 4
0
 private void Start()
 {
     /* LevelGate = GameObject.Find("LevelGate");
      * if(LevelGate != null)
      * {
      *   Door = LevelGate.transform.Find("Door").gameObject;
      * }
      * else { Debug.Log("cannot find a level gate"); }
      */
     //resourceController = FindObjectOfType<AMS_ResourceController>();
     TargetIndicator          = GameObject.Find("TargetIndicator");
     Arrow                    = TargetIndicator.transform.Find("Arrow").gameObject;
     WinningItemSpawnerScript = FindObjectOfType <WinningItemSpawnerScript>();
     //     WinningItemScript = WinningItemSpawnerScript.GetComponent<WinningItem>();
     MainPlayerScript = FindObjectOfType <KE_MainPlayer_Script>();
     Base             = GameObject.Find("Base");
     Arrow.SetActive(false);
 }
Exemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        //General Gun Setup
        currentGun      = gun1;
        maxAmmo         = gun1maxAmmo;
        currentAmmo     = maxAmmo;
        currentClips    = gun1currentClips;
        maxFireRate     = gun1maxFireRate;
        currentBullet   = gun1Bullet;
        currentFireRate = maxFireRate;

        //Gun 1 Setup
        gun1currentAmmo = maxAmmo;
        //Laser Setup
        LaserColor();


        defaultAlternateFireAmmo          = maxDefaultAlrernateFireAmmo;
        defaultAlternativeCurrentFireRate = defaultAlternativeMaxFireRate * 2;
        AlternateAmmoText  = GameObject.Find("Alternate_Ammo_Text").GetComponent <Text>(); //Grabbing the text so it doesn't need to be assigned in the inspector
        PrimaryWeaponGUI   = GameObject.Find("PrimaryWeapon");                             //Primary Weapon GUI
        SecondaryWeaponGUI = GameObject.Find("SecondaryWeapon");                           // Secondary Weapon GUI
        SecondaryWeaponGUI.GetComponentInChildren <Text>().color = InactiveWeaponColor;
        SecondaryWeaponGUI.SetActive(false);
        AlternateAmmoImage        = GameObject.Find("Grenade"); // Finds the Grenade Image
        PrimaryActiveWeaponName   = GameObject.Find("PrimaryActiveWeaponName").GetComponent <Text>();
        SecondaryActiveWeaponName = GameObject.Find("SecondaryActiveWeaponName").GetComponent <Text>();
        ActiveWeapon = GameObject.Find("ActiveWeapon"); // Find the Active Weapon Game Object on the Main Camera Prefab / PlayerGUI/ Canvas
        ActiveWeapon.SetActive(false);
        PrimaryActiveWeaponName.enabled   = true;
        SecondaryActiveWeaponName.enabled = true;
        SecondaryActiveWeaponName.GetComponentInChildren <Text>().color = InactiveWeaponColor;
        powerupDisplay = GameObject.Find("Powerup_GUI").GetComponent <Image>();
        powerupDisplay.gameObject.SetActive(false); // turns off the powerup display on start.
        OutOfAmmo = GameObject.Find("OutOfAmmo");
        OutOfAmmo.SetActive(false);
        mainPlayerScript = GetComponent <KE_MainPlayer_Script>();

        if (defaultGun != null)
        {
            defaultGun.SetActive(true);
        }
    }
    void Start()
    {
        menuController = FindObjectOfType <MenuController>();
        playerDead     = false;
        currentHealth  = maxHealth;
        if (gameObject.tag == "Player")
        {
            mainPlayerScript = GetComponent <KE_MainPlayer_Script>();
        }
        isTakingDamage = false;

        baseScale    = transform.localScale.y;
        currentScale = baseScale;

        amDead = false;
        // GunManagementScript = GameObject.Find("MainPlayer").GetComponent<AMS_GunManagement>();
        // currentBullet = GunManagementScript.currentBullet;
        // currentBulletScript = currentBullet.GetComponent<AMS_Bullet>();
    }
Exemplo n.º 7
0
    //Creates a .dat file in the project for saving purposes
    public static void Save(KE_MainPlayer_Script player)
    {
        BinaryFormatter bf       = new BinaryFormatter();
        string          path     = Application.persistentDataPath + "/playerInfo.dat";
        FileStream      savefile = new FileStream(path, FileMode.Create);

        //After Binary setup, gives the ability to write to the disk.
        PlayerData data = new PlayerData(player);

        Debug.Log("Game Saved at " + path);
        Debug.Log("Player health saved as  " + data.health);
        Debug.Log("Player clips1 saved as  " + data.ammoClips1);
        Debug.Log("Player clips2 saved as  " + data.ammoClips2);
        Debug.Log("Player ammo1 saved as  " + data.ammo1);
        Debug.Log("Player ammo2 saved as  " + data.ammo2);
        Debug.Log("current level saved as  " + data.currentLevel);

        bf.Serialize(savefile, data);
        savefile.Close();
    }