Example #1
0
    private void Awake()
    {
        hud = Instantiate(healthHUD, transform).transform;
        if (!hud.gameObject.activeSelf)
        {
            hud.gameObject.SetActive(true);
        }

        totalHealth      = health;
        healthBar        = hud.transform.Find("Bar").GetComponent <RectTransform>();
        healthUI         = hud.GetComponent <HealthHUD>();
        originalBarScale = healthBar.sizeDelta.x;
        anim             = GetComponent <Animator>();
        controller       = GetComponent <StateController>();
        gameController   = GameObject.FindGameObjectWithTag("GameController");

        foreach (Transform child in anim.GetBoneTransform(HumanBodyBones.RightHand))
        {
            weapon = child.Find("muzzle");
            if (weapon != null)
            {
                break;
            }
        }
        weapon = weapon.parent;
    }
    void Awake()
    {
        Instance = this;

        maxHealth = Hearts.Length * 2;
        if (PlayerPrefs.HasKey("Health"))
        {
            Health = PlayerPrefs.GetInt("Health");
        }
        else
        {
            Health = maxHealth;
        }
    }
    public void SetEntity(Vector2 pos, bool isPlayer)
    {
        health = maxHealth;

        this.isPlayer = isPlayer;
        isDead        = false;

        playerScript    = playerObject.GetComponent <Player>();
        top_animator    = Global.getChildGameObject(gameObject, "Animation_top").GetComponent <Animator>();
        bottom_animator = Global.getChildGameObject(gameObject, "Animation_bottom").GetComponent <Animator>();

        mirrored          = false;
        onGround          = false;
        collidingWithWall = false;
        skipNextMove      = false;
        fallTroughBar     = false;
        underBar          = false;
        attackDone        = false;
        dustOnce          = false;
        maxDrunk          = false;
        checkDrunkTimer   = true;
        useMpu            = playerScript.useMpu;
        if (chosenCharacter == Player.Character.FAIRY)
        {
            canDoubleJump = true;
        }
        else
        {
            canDoubleJump = false;
        }

        isHit       = false;
        isAttacking = false;
        isBlocking  = false;
        isDashing   = false;
        isDrinking  = false;

        jumpOnce         = 0;
        attackOnce       = 0;
        attackCooldown   = 0;
        drinkAnimCounter = 0;
        drunkness        = 0;
        drunknessF       = 0f;
        drunkWalkTimer   = 0;
        deathCounter     = 0;

        hitDirection = "filler";

        lastVelocity = new Vector2(0, 2);

        sortOfDrink = Drink.SortOfDrink.NONE;
        Direction   = Facing.RIGHT;

        groundCheck  = Global.getChildGameObject(gameObject, "GroundCheck");
        punchCheck   = Global.getChildGameObject(gameObject, "PunchCheck");
        bodyCheck    = Global.getChildGameObject(gameObject, "BodyCheck");
        wallCheck    = Global.getChildGameObject(gameObject, "WallCheck");
        dustParticle = Global.getChildGameObject(gameObject, "Dust particle");
        groundLayer  = playerObject.GetComponent <LayerMaskPass>().GetLayerMask();

        respawnButtonPos = new Vector2(transform.position.x, transform.position.y - 40);
        healthHud        = playerScript.healthHUD.GetComponentInChildren <HealthHUD>();
        healthHud.SetHealth(health);

        advancedCamera     = Camera.main.GetComponent <AdvancedCamera>();
        this.mpuController = playerScript.mpuController;

        SetDictionary();
    }
Example #4
0
    public void SetPlayer(int controlNumber, Character chosenChar, bool mpu, string com)
    {
        controllerNumber = controlNumber;
        chosenCharacter  = chosenChar;
        switch (chosenCharacter)
        {
        case Character.LEPRECHAUN_01:
            loadCharacterString = "Prefabs/Entities/Leprechaun_01";

            healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_leprechaun01"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
            healthHUD.transform.parent = Camera.main.transform;
            healthHUDScript            = healthHUD.GetComponentInChildren <HealthHUD>();
            healthHUDScript.SetHealthHud(controllerNumber);
            break;

        case Character.LEPRECHAUN_USA:
            loadCharacterString = "Prefabs/Entities/Leprechaun_usa";

            healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_leprechaunusa"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
            healthHUD.transform.parent = Camera.main.transform;
            healthHUDScript            = healthHUD.GetComponentInChildren <HealthHUD>();
            healthHUDScript.SetHealthHud(controllerNumber);
            break;

        case Character.CLUIRICHAUN:
            loadCharacterString = "Prefabs/Entities/Cluirichaun";

            healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_cluirichaun"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
            healthHUD.transform.parent = Camera.main.transform;
            healthHUDScript            = healthHUD.GetComponentInChildren <HealthHUD>();
            healthHUDScript.SetHealthHud(controllerNumber);
            break;

        case Character.FAR_DARRIG:
            loadCharacterString = "Prefabs/Entities/FarDarrig";

            healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_fardarrig"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
            healthHUD.transform.parent = Camera.main.transform;
            healthHUDScript            = healthHUD.GetComponentInChildren <HealthHUD>();
            healthHUDScript.SetHealthHud(controllerNumber);
            break;

        case Character.FAIRY:
            loadCharacterString = "Prefabs/Entities/Fairy";

            healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_fairy"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
            healthHUD.transform.parent = Camera.main.transform;
            healthHUDScript            = healthHUD.GetComponentInChildren <HealthHUD>();
            healthHUDScript.SetHealthHud(controllerNumber);
            break;

        default:
            loadCharacterString = "Prefabs/Entities/Leprechaun_01";

            healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_leprechaun01"), new Vector3(-10 + (5 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
            healthHUD.transform.parent = Camera.main.transform;
            healthHUDScript            = healthHUD.GetComponentInChildren <HealthHUD>();
            healthHUDScript.SetHealthHud(controllerNumber);
            print("You done goofed hard.");
            break;
        }

        RESET  = false;
        useMpu = mpu;
        if (useMpu)
        {
            COMParser compars = gameObject.AddComponent <COMParser>();
            compars.com   = com;
            mpuController = gameObject.AddComponent <MPUController>();
        }
        kills = 0;



        playerStartPosition           = new Vector3(-10 + (4 * controllerNumber), 0, (-.1f * controllerNumber));
        gameObject.transform.position = playerStartPosition;

        leprechaunObject = Instantiate(Resources.Load(loadCharacterString), transform.position, Quaternion.identity) as GameObject;
        leprechaunObject.transform.parent = gameObject.transform;
        switch (chosenCharacter)
        {
        case Character.LEPRECHAUN_01:
            leprechaunScript = leprechaunObject.AddComponent <Leprechaun>();
            Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
            leprechaunScript.GetComponent <Leprechaun>().SetLeprechaun(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
            break;

        case Character.LEPRECHAUN_USA:
            leprechaunScript = leprechaunObject.AddComponent <Leprechaun_USA>();
            Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
            leprechaunScript.GetComponent <Leprechaun_USA>().SetLeprechaun_USA(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
            break;

        case Character.CLUIRICHAUN:
            leprechaunScript = leprechaunObject.AddComponent <Cluirichaun>();
            Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
            leprechaunScript.GetComponent <Cluirichaun>().SetCluirichaun(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
            gameObject.GetComponent <BoxCollider2D>().size   = leprechaunScript.GetComponent <Cluirichaun>().bodyCheck.GetComponent <BoxCollider2D>().size;
            gameObject.GetComponent <BoxCollider2D>().center = leprechaunScript.GetComponent <Cluirichaun>().bodyCheck.GetComponent <BoxCollider2D>().center;
            break;

        case Character.FAR_DARRIG:
            leprechaunScript = leprechaunObject.AddComponent <FarDarrig>();
            Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
            leprechaunScript.GetComponent <FarDarrig>().SetFarDarrig(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
            gameObject.GetComponent <BoxCollider2D>().size   = leprechaunScript.GetComponent <FarDarrig>().bodyCheck.GetComponent <BoxCollider2D>().size;
            gameObject.GetComponent <BoxCollider2D>().center = leprechaunScript.GetComponent <FarDarrig>().bodyCheck.GetComponent <BoxCollider2D>().center;
            break;

        case Character.FAIRY:
            leprechaunScript = leprechaunObject.AddComponent <Fairy>();
            Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
            leprechaunScript.GetComponent <Fairy>().SetFairy(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
            gameObject.GetComponent <BoxCollider2D>().size   = leprechaunScript.GetComponent <Fairy>().bodyCheck.GetComponent <BoxCollider2D>().size;
            gameObject.GetComponent <BoxCollider2D>().center = leprechaunScript.GetComponent <Fairy>().bodyCheck.GetComponent <BoxCollider2D>().center;
            break;

        default:
            break;
        }

        Global.leprechauns.Add(leprechaunObject);

        Vector3 playerIndPos = new Vector3(transform.position.x, transform.position.y + 1, 0);

        playerIndicatorObject = Instantiate(Resources.Load("Prefabs/Objects/HUD/Controller_indicator"), playerIndPos, Quaternion.identity) as GameObject;
        playerIndicatorScript = playerIndicatorObject.GetComponent <PlayerIndicator>();
        playerIndicatorScript.SetIndicator(gameObject, controllerNumber);



        //gridPos = leprechaun.GetGridPosition();
        //respawnFlare = new RespawnFlare(leprechaun.GetPosition, controllerNumber);
    }
Example #5
0
 private void Awake()
 {
     instance = this;
 }
Example #6
0
 void Awake()
 {
     instance   = this;
     hpHUD_text = GetComponent <TextMeshProUGUI>();
 }
    public void SetEntity(Vector2 pos, bool isPlayer)
    {
        health = maxHealth;

        this.isPlayer = isPlayer;
        isDead = false;

        playerScript = playerObject.GetComponent<Player>();
        top_animator = Global.getChildGameObject(gameObject, "Animation_top").GetComponent<Animator>();
        bottom_animator = Global.getChildGameObject(gameObject, "Animation_bottom").GetComponent<Animator>();

        mirrored = false;
        onGround = false;
        collidingWithWall = false;
        skipNextMove = false;
        fallTroughBar = false;
        underBar = false; 
        attackDone = false;
        dustOnce = false;
        maxDrunk = false;
        checkDrunkTimer = true;
        useMpu = playerScript.useMpu;
        if (chosenCharacter == Player.Character.FAIRY)
            canDoubleJump = true;
        else
            canDoubleJump = false;

        isHit = false;
        isAttacking = false;
        isBlocking = false;
        isDashing = false;
        isDrinking = false;
        
        jumpOnce = 0;
        attackOnce = 0;
        attackCooldown = 0;
        drinkAnimCounter = 0;
        drunkness = 0;
        drunknessF = 0f;
        drunkWalkTimer = 0;
        deathCounter = 0;

        hitDirection = "filler";

        lastVelocity = new Vector2(0, 2);

        sortOfDrink = Drink.SortOfDrink.NONE;
        Direction = Facing.RIGHT;

        groundCheck = Global.getChildGameObject(gameObject, "GroundCheck");
        punchCheck = Global.getChildGameObject(gameObject, "PunchCheck");
        bodyCheck = Global.getChildGameObject(gameObject, "BodyCheck");
        wallCheck = Global.getChildGameObject(gameObject, "WallCheck");
        dustParticle = Global.getChildGameObject(gameObject, "Dust particle");
        groundLayer = playerObject.GetComponent<LayerMaskPass>().GetLayerMask();
        
        respawnButtonPos = new Vector2(transform.position.x, transform.position.y - 40);
        healthHud = playerScript.healthHUD.GetComponentInChildren<HealthHUD>();
        healthHud.SetHealth(health);

        advancedCamera = Camera.main.GetComponent<AdvancedCamera>();
        this.mpuController = playerScript.mpuController;
        
        SetDictionary();
    }
    public void SetPlayer(int controlNumber, Character chosenChar, bool mpu, string com)
    {
        controllerNumber = controlNumber;
        chosenCharacter = chosenChar;
        switch (chosenCharacter)
        {
            case Character.LEPRECHAUN_01:
                loadCharacterString = "Prefabs/Entities/Leprechaun_01";
                
                healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_leprechaun01"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
                healthHUD.transform.parent = Camera.main.transform;
                healthHUDScript = healthHUD.GetComponentInChildren<HealthHUD>();
                healthHUDScript.SetHealthHud(controllerNumber);
                break;
            case Character.LEPRECHAUN_USA:
                loadCharacterString = "Prefabs/Entities/Leprechaun_usa";
                
                healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_leprechaunusa"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
                healthHUD.transform.parent = Camera.main.transform;
                healthHUDScript = healthHUD.GetComponentInChildren<HealthHUD>();
                healthHUDScript.SetHealthHud(controllerNumber);
                break;
            case Character.CLUIRICHAUN:
                loadCharacterString = "Prefabs/Entities/Cluirichaun";
                
                healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_cluirichaun"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
                healthHUD.transform.parent = Camera.main.transform;
                healthHUDScript = healthHUD.GetComponentInChildren<HealthHUD>();
                healthHUDScript.SetHealthHud(controllerNumber);
                break;
            case Character.FAR_DARRIG:
                loadCharacterString = "Prefabs/Entities/FarDarrig";
                
                healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_fardarrig"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
                healthHUD.transform.parent = Camera.main.transform;
                healthHUDScript = healthHUD.GetComponentInChildren<HealthHUD>();
                healthHUDScript.SetHealthHud(controllerNumber);
                break;
            case Character.FAIRY:
                loadCharacterString = "Prefabs/Entities/Fairy";
                
                healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_fairy"), new Vector3(-10 + (4 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
                healthHUD.transform.parent = Camera.main.transform;
                healthHUDScript = healthHUD.GetComponentInChildren<HealthHUD>();
                healthHUDScript.SetHealthHud(controllerNumber);
                break;
            default:
                loadCharacterString = "Prefabs/Entities/Leprechaun_01";
                
                healthHUD = Instantiate(Resources.Load("Prefabs/Objects/HUD/HUD_health_leprechaun01"), new Vector3(-10 + (5 * controllerNumber), -3, -9), Quaternion.identity) as GameObject;
                healthHUD.transform.parent = Camera.main.transform;
                healthHUDScript = healthHUD.GetComponentInChildren<HealthHUD>();
                healthHUDScript.SetHealthHud(controllerNumber);
                print("You done goofed hard.");
                break;
        }

        RESET = false;
        useMpu = mpu;
        if (useMpu)
        {
            COMParser compars = gameObject.AddComponent<COMParser>();
            compars.com = com;
            mpuController = gameObject.AddComponent<MPUController>();
        }
        kills = 0;



        playerStartPosition = new Vector3(-10 + (4 * controllerNumber), 0, (-.1f * controllerNumber));
        gameObject.transform.position = playerStartPosition;

        leprechaunObject = Instantiate(Resources.Load(loadCharacterString), transform.position, Quaternion.identity) as GameObject;
        leprechaunObject.transform.parent = gameObject.transform;
        switch (chosenCharacter)
        {
            case Character.LEPRECHAUN_01:
                leprechaunScript = leprechaunObject.AddComponent<Leprechaun>();
                Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
                leprechaunScript.GetComponent<Leprechaun>().SetLeprechaun(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
                break;
            case Character.LEPRECHAUN_USA:
                leprechaunScript = leprechaunObject.AddComponent<Leprechaun_USA>();
                Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
                leprechaunScript.GetComponent<Leprechaun_USA>().SetLeprechaun_USA(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
                break;
            case Character.CLUIRICHAUN:
                leprechaunScript = leprechaunObject.AddComponent<Cluirichaun>();
                Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
                leprechaunScript.GetComponent<Cluirichaun>().SetCluirichaun(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
                gameObject.GetComponent<BoxCollider2D>().size = leprechaunScript.GetComponent<Cluirichaun>().bodyCheck.GetComponent<BoxCollider2D>().size;
                gameObject.GetComponent<BoxCollider2D>().center = leprechaunScript.GetComponent<Cluirichaun>().bodyCheck.GetComponent<BoxCollider2D>().center;
                break;
            case Character.FAR_DARRIG:
                leprechaunScript = leprechaunObject.AddComponent<FarDarrig>();
                Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
                leprechaunScript.GetComponent<FarDarrig>().SetFarDarrig(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
                gameObject.GetComponent<BoxCollider2D>().size = leprechaunScript.GetComponent<FarDarrig>().bodyCheck.GetComponent<BoxCollider2D>().size;
                gameObject.GetComponent<BoxCollider2D>().center = leprechaunScript.GetComponent<FarDarrig>().bodyCheck.GetComponent<BoxCollider2D>().center;
                break;
            case Character.FAIRY:
                leprechaunScript = leprechaunObject.AddComponent<Fairy>();
                Global.lepGOlepScript.Add(leprechaunObject, leprechaunScript.ToString());
                leprechaunScript.GetComponent<Fairy>().SetFairy(playerStartPosition, controllerNumber, chosenCharacter, gameObject);
                gameObject.GetComponent<BoxCollider2D>().size = leprechaunScript.GetComponent<Fairy>().bodyCheck.GetComponent<BoxCollider2D>().size;
                gameObject.GetComponent<BoxCollider2D>().center = leprechaunScript.GetComponent<Fairy>().bodyCheck.GetComponent<BoxCollider2D>().center;
                break;
            default:
                break;
        }

        Global.leprechauns.Add(leprechaunObject);

        Vector3 playerIndPos = new Vector3(transform.position.x, transform.position.y + 1, 0);
        playerIndicatorObject = Instantiate(Resources.Load("Prefabs/Objects/HUD/Controller_indicator"), playerIndPos, Quaternion.identity) as GameObject;
        playerIndicatorScript = playerIndicatorObject.GetComponent<PlayerIndicator>();
        playerIndicatorScript.SetIndicator(gameObject, controllerNumber);



        //gridPos = leprechaun.GetGridPosition();
        //respawnFlare = new RespawnFlare(leprechaun.GetPosition, controllerNumber);


    }
Example #9
0
 private void Start()
 {
     Health = startingHealth;
     hphud  = FindObjectOfType <HealthHUD>();
     UpdateUI();
 }