コード例 #1
0
    // Use this for initialization
    void Start()
    {
        selectedCharacter = UnityEngine.Random.Range(1, 5);
        joystickCounter   = selectedCharacter;
        offset            = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        offset_temp       = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        scale_temp        = new Vector2((1 / numberOfCharacters), 1);
        startPos          = gameObject.transform.position;

        playerIndexInt = GamePad.IndexToInt(player);

        sprite = gameObject.renderer.material;
        sprite.mainTexture.wrapMode = TextureWrapMode.Repeat;
        sprite.mainTextureOffset    = offset;
        sprite.mainTextureScale     = scale;

        colorFlash   = gameObject.GetComponent <ColorFlash>();
        selectButton = Instantiate(Resources.Load("Prefabs/Screens/MenuScreen/Character_Select_SelectButton"), new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity) as GameObject;
        selectButton.transform.parent = gameObject.transform.parent;
        selectButton.SetActive(false);

        useMPU = GameObject.FindGameObjectWithTag("Global").GetComponent <MenuToGame>().mpus[playerIndexInt - 1];

        if (useMPU)
        {
            tempCom       = gameObject.transform.parent.GetComponent <COMParser>().com;
            mpuController = gameObject.AddComponent <MPUController>();
            mpuController.controllerNumber = playerIndexInt;
        }

        Invoke("AddPlayerCharacter", 0.01f);
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        selectedCharacter = UnityEngine.Random.Range(1, 5);
        joystickCounter = selectedCharacter;
        offset = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        offset_temp = new Vector2((1 / numberOfCharacters) * selectedCharacter, 0);
        scale_temp = new Vector2((1 / numberOfCharacters), 1);
        startPos = gameObject.transform.position;

        playerIndexInt = GamePad.IndexToInt(player);

        sprite = gameObject.renderer.material;
        sprite.mainTexture.wrapMode = TextureWrapMode.Repeat;
        sprite.mainTextureOffset = offset;
        sprite.mainTextureScale = scale;

        colorFlash = gameObject.GetComponent<ColorFlash>();
        selectButton = Instantiate(Resources.Load("Prefabs/Screens/MenuScreen/Character_Select_SelectButton"), new Vector3(transform.position.x, transform.position.y, -.5f), Quaternion.identity) as GameObject;
        selectButton.transform.parent = gameObject.transform.parent;
        selectButton.SetActive(false);

        useMPU = GameObject.FindGameObjectWithTag("Global").GetComponent<MenuToGame>().mpus[playerIndexInt - 1];

        if (useMPU)
        {
            tempCom = gameObject.transform.parent.GetComponent<COMParser>().com;
            mpuController = gameObject.AddComponent<MPUController>();
            mpuController.controllerNumber = playerIndexInt;
        }

        Invoke("AddPlayerCharacter", 0.01f);
    }
コード例 #3
0
    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();
    }
コード例 #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);
    }
コード例 #5
0
    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();
    }
コード例 #6
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);


    }