コード例 #1
0
    private int InitializeBoard()
    {
        //Incrément du noms des cases
        numberOfCases = 0;
        // l'utilisation d'hexagones/cercles impose une décalage une rangée sur 2.
        décalage_x = 0f;

        for (int i = 1; i <= Board_size; i++)
        {
            for (int j = 1; j <= Board_size; j++)
            {
                //Set up du décalage
                if (i % 2 == 0)
                {
                    décalage_x = CASE_WIDTH / 2f;
                }
                else
                {
                    décalage_x = 0f;
                }
                GameObject CaseObject = (GameObject)Instantiate(CasePrefab);
                //Case_script Case =  CaseObject.AddComponent<Case_script>();
                Case_script Case = CaseObject.AddComponent <Case_script>();
                Case.id = numberOfCases;
                /* CaseObject.transform.parent = transform; */
                CaseObject.name = "Case n°" + numberOfCases;
                Liste_cases.Add(numberOfCases, Case);
                //Debug.Log("Case ajoutée:" + Case);
                //Case.Position = new Vector3 (i*CASE_WIDTH+décalage_x,0,j*CASE_DIAGONAL);
                CaseObject.transform.position = new Vector3(j * CASE_WIDTH + décalage_x, 0, i * CASE_DIAGONAL);
                //Génération aléatoire du terrain
                int rand = Random.Range(0, 16);
                if (rand <= 3f)
                {
                    Terrain = "Rivière";
                }
                if (rand > 3f && rand <= 8f)
                {
                    Terrain = "Plaine";
                }
                if (rand > 8f && rand <= 12f)
                {
                    Terrain = "Montagne";
                }
                if (rand > 12f)
                {
                    Terrain = "Forêt";
                }
                CaseObjectMaterial = Resources.Load <Material>("Textures/" + Terrain);
                MeshRenderer meshRenderer = CaseObject.GetComponent <MeshRenderer>();
                // Set the new material on the GameObject
                meshRenderer.material = CaseObjectMaterial;
                Case.Terrain          = CaseObjectMaterial;
                numberOfCases++;
            }
        }
        InitializeNeighbourCases();
        return(0);
    }
コード例 #2
0
    public void Move_B_UI_update(GameObject Object)
    {
        Case_script CaseValues = Object.GetComponent <Case_script>();

        destination_icon.material = Resources.Load <Material>("Textures/UI_" + CaseValues.Terrain.name);
        destination_text.text     = CaseValues.Terrain.name;

        UI_values.Step = UI_Manager_script.StepType.ReadyMove;
        ElementB       = Object;
    }
コード例 #3
0
    //UI update Methods
    public void Intel_UI_update(GameObject Object)
    {
        //Find object type and display according to
        switch (WhatKindOfObjectIsThisOne(Object))
        {
        case TokenType.Default:
            Debug.Log("Object Type cannot be defined");
            break;

        case TokenType.Unit:
            Unit_script UnitValues = Object.GetComponent <Unit_script>();
            //Display
            Image_icon.material = Resources.Load <Material>("Textures/UI_" + UnitValues.type);
            TYPE_text.text      = UnitValues.type.ToString();
            HV_text.text        = UnitValues.health.ToString();
            HL_text.text        = UnitValues.H_limit.ToString();
            AV_text.text        = UnitValues.ammo.ToString();
            AL_text.text        = UnitValues.A_limit.ToString();
            MV_text.text        = UnitValues.mvt.ToString();
            ML_text.text        = UnitValues.M_limit.ToString();
            Player_text.text    = "P" + UnitValues.Owner.ToString();
            break;

        case TokenType.Building:
            Batiment_script BuildingValues = Object.GetComponent <Batiment_script>();
            //Display
            Image_icon.material = Resources.Load <Material>("Textures/UI_" + BuildingValues.type);
            TYPE_text.text      = BuildingValues.type.ToString();
            HV_text.text        = "";
            HL_text.text        = "";
            AV_text.text        = "";
            AL_text.text        = "";
            MV_text.text        = "";
            ML_text.text        = "";
            Player_text.text    = "";
            break;

        case TokenType.Case:
            Case_script CaseValues = Object.GetComponent <Case_script>();
            //Display
            Image_icon.material = Resources.Load <Material>("Textures/UI_" + CaseValues.Terrain.name);
            TYPE_text.text      = CaseValues.Terrain.name.ToString();
            HV_text.text        = "N/A";
            HL_text.text        = "N/A";
            AV_text.text        = "N/A";
            AL_text.text        = "N/A";
            MV_text.text        = "N/A";
            ML_text.text        = "N/A";
            Player_text.text    = CaseValues.Occupation.ToString();
            break;
        }
    }
コード例 #4
0
ファイル: Case_script.cs プロジェクト: MADcrea/ADVW
    bool CheckVoisine(Case_script Case_to_check)
    {
        bool returnValue = false;

        foreach (Case_script CaseVoisine in Cases_voisines)
        {
            if (CaseVoisine == Case_to_check)
            {
                returnValue = true;
            }
        }
        return(returnValue);
    }
コード例 #5
0
ファイル: Case_script.cs プロジェクト: MADcrea/ADVW
    private void OnMouseUp()
    {
        //Phase 1 Step Case selection for unit
        if (UI_values.Phase_number == 1 && UI_values.Step == UI_Manager_script.StepType.Token_creation_case)
        {
            //Check if case is free
            if (Occupation == OccupationType.Free)
            {
                //Check if valid building is near
                if (true /*HasCaseAnAdjacentAllyBuilding()*/)
                {
                    //Send Case adress to GameManager (HUD1)
                    HUD1Value.Unit_Deployment(this.gameObject);
                }
            }
        }

        //Phase 2 Step Intel
        if (UI_values.Phase_number == 2 && UI_values.Step == UI_Manager_script.StepType.Intel)
        {
            HUD2Value.Intel_UI_update(this.gameObject);
        }

        //Phase 2 Step Move B
        if (UI_values.Phase_number == 2 && UI_values.Step == UI_Manager_script.StepType.DefineDestination)
        {
            if (Occupation == OccupationType.Free) //Case must be free
            {
                GameObject  Voyager        = HUD2Value.ElementA;
                Unit_script Voyager_values = Voyager.GetComponent <Unit_script>();
                //Debug.Log(Voyager.name);
                Case_script Origin_Case = Voyager_values.Occupied_case.GetComponent <Case_script>();
                if (CheckVoisine(Origin_Case)) //Case must be adjacente
                {
                    HUD2Value.Move_B_UI_update(this.gameObject);
                }
                else
                {
                    Debug.Log("This case is not a good choice");
                }
            }
            else
            {
                Debug.Log("Destination is not free");
            }
        }
    }
コード例 #6
0
ファイル: HUD1_script.cs プロジェクト: MADcrea/ADVW
    public void Unit_Deployment(GameObject Deployment_Case)
    {
        if (IsThisTerrainAcceptableForSuchUnit(Deployment_Case))
        {
            //GameObject Selected_case => Case_script
            Case_script Deployment_zone = Deployment_Case.GetComponent <Case_script>();
            //Unit_creation
            GameObject  NewUnit      = (GameObject)Instantiate(UnitPrefab);
            Unit_script NewUnitValue = NewUnit.GetComponent <Unit_script>();
            //Unit Set_up
            //GameObject
            NewUnit.name = "UNIT_" + UnitDeployed;
            NewUnit.transform.position = Deployment_Case.transform.position + new Vector3(0, 0.2f, 0);
            //Unit values
            NewUnitValue.Owner         = UI_values.Player_turn;
            NewUnitValue.Occupied_case = Deployment_zone;
            NewUnitValue.Set_up_unit_values(Unit_To_Be_Deployed);
            //Color
            NewUnitValue.Change_Color();

            //Case update
            Deployment_zone.OccupingUnit = NewUnitValue;
            Deployment_zone.Occupation   = Case_script.OccupationType.Unit;

            //Player Update
            //Ressources
            Ressources_Payment(Unit_To_Be_Deployed);

            //Miscellaneous
            UnitDeployed++;
            UI_values.Step = UI_Manager_script.StepType.none;
            Intel.text     = "P" + UI_values.Player_turn + " created " + Unit_To_Be_Deployed;
        }
        else
        {
            Intel.text = "Terrain not suitable for " + Unit_To_Be_Deployed.ToString();
        }
    }
コード例 #7
0
    public void Move_Perform(int a)
    {
        if (UI_values.Step == UI_Manager_script.StepType.ReadyMove)
        {
            GameObject  Voyager            = ElementA;
            Unit_script Voyager_values     = Voyager.GetComponent <Unit_script>();
            Case_script Origin_Case        = Voyager_values.Occupied_case.GetComponent <Case_script>();
            GameObject  destination        = ElementB;
            Case_script destination_values = destination.GetComponent <Case_script>();

            //Remplace l'occupation de la case occupée avant le mouvement par l'unité
            Origin_Case.Occupation = Case_script.OccupationType.Free;
            //Le token unité bouge à son nouvel emplacement
            Voyager.transform.position   = destination.transform.position + new Vector3(0, 0.2f, 0);
            Voyager_values.Occupied_case = destination_values;
            //La case destination est occupée
            destination_values.Occupation     = Case_script.OccupationType.Unit;
            destination_values.Owning_control = Voyager_values.Owner;
            //L'unité perd un mouvement
            Voyager_values.Change_Mvt_stock(-1f);

            Move_Cancel(1);
        }
    }
コード例 #8
0
ファイル: Case_script.cs プロジェクト: MADcrea/ADVW
 public void AddNeighbour(Case_script CaseToAdd)
 {
     Cases_voisines.Add(CaseToAdd);
 }