コード例 #1
0
 // Use this for initialization
 void Start()
 {
     playerIndicatorComponent = GetComponent <PlayerIndicator>();
     playerMovmentComponent   = GetComponentInParent <Movement>();
     spriteRendererComponent  = GetComponent <SpriteRenderer>();
 }
コード例 #2
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);


    }
コード例 #3
0
 public static PlayerIndicator Opposite(this PlayerIndicator indicator)
 => indicator == PlayerIndicator.Top
         ? PlayerIndicator.Bot
         : PlayerIndicator.Top;