Example #1
0
    void spawnAlly()
    {
        AllyController a = (AllyController)Instantiate(ally);

        people.Add(a);
        a.gm = this;
    }
Example #2
0
    public void Incarnate(AllyController ally)
    {
        Debug.Log("Incarnated");
        UnitSelector.instance.BlockSelection = true;


        Hand hand = player.GetHand(handType);

        if (hand == null)
        {
            hand = player.GetHand(SteamVR_Input_Sources.Any);
        }
        this.hand      = hand;
        objectInstance = Instantiate(ally.configuration.leftObject);
        objectInstance.transform.position = hand.transform.position;

        objectInstance.AttachToHand(hand);

        transform.position = ally.transform.position;
        var camera = GetComponentInChildren <Camera>();
        //camera.transform.forward = ally.transform.forward;
        var     forwardRotation = ally.transform.rotation * Quaternion.Inverse(camera.transform.rotation);
        Vector3 newRotattion    = new Vector3(0f, forwardRotation.eulerAngles.y, 0f);

        transform.rotation = Quaternion.Euler(newRotattion);
        belt.ConfigureBelt(ally.configuration);
        belt.gameObject.SetActive(true);
        ally.gameObject.SetActive(false);

        CharacterStats cs = ally.GetComponent <CharacterStats>();

        incarnatedAlly = cs;
        currentHealth  = cs.CurrentHealth;
        isIncarnated   = true;
    }
Example #3
0
    public void turninQuest(AllyController turninTo, int questID)
    {
        Quest q = getQuest(questID);

        if (q != null)
        {
            if (q.getQuestGiver() == turninTo)
            {
                if (q.isComplete())
                {
                    q.giveReward(questLogOwner);
                    quests.Remove(q);
                }
                else
                {
                    Debug.Log("Quest not yet ready to turn in");
                }
            }
            else
            {
                //quest not turned in to correct person
                Debug.Log("Quest not turned in to correct person");
            }
        }
        else
        {
            //quest does not exist in log
            Debug.Log("Quest not found in questlog");
        }
    }
Example #4
0
    private void Start()
    {
        ally     = GetComponent <AllyController>();
        anim     = GetComponent <Animator>();
        shoulder = anim.GetBoneTransform(HumanBodyBones.RightUpperArm).transform;

        aimPivot                  = new GameObject().transform;
        aimPivot.name             = "aim_pivot";
        aimPivot.transform.parent = transform;

        r_Hand                  = new GameObject().transform;
        r_Hand.name             = "right_hand";
        r_Hand.transform.parent = aimPivot;

        l_Hand                  = new GameObject().transform;
        l_Hand.name             = "left_hand";
        l_Hand.transform.parent = aimPivot;

        Main_Weapon_Setting();
        Sub_Weapon_Setting();
        Third_Weapon_Setting();
        Right_hand_setting();

        AI_IKweaponState = ally.weaponType;
    }
Example #5
0
    public void AsignPosition()
    {
        if (allyMove != null)
        {
            foreach (var hand in hands)
            {
                if (SteamVR_Input.GetStateDown("Shoot", hand.handType))
                {
                    HandSelector hs = hand.GetComponentInChildren <HandSelector>();
                    if (hs != null)
                    {
                        Ray        ray = new Ray(hs.transform.position, hs.transform.forward);
                        RaycastHit hit;
                        if (Physics.Raycast(ray, out hit, 50f))
                        {
                            Debug.Log(hit.transform.gameObject);
                            allyMove.SetPoint(hit.point);
                        }

                        allyMove = null;
                    }
                }
            }
        }
    }
Example #6
0
    void Start()
    {
        // Hit sound
        source = GetComponent <AudioSource>();

        // Ship reference
        ship = GetComponentInParent <AllyController>();
    }
Example #7
0
 public static void initRandomQuest(AllyController owner)
 {
     if (owner.questToGive == null && owner.leader == null)
     {
         QuestObjective randObjective = (QuestObjective)Random.Range(0, System.Enum.GetValues(typeof(QuestObjective)).Length - 1);
         owner.questToGive = new Quest(owner, randObjective, (randObjective.Equals(QuestObjective.KILL) ? 1 : Random.Range(2, 4)), (int)Random.Range(3, 10));
     }
 }
Example #8
0
 // Use this for initialization
 void Start()
 {
     allyController = GameObject.Find("FriendlyController").GetComponent<AllyController>();
     enemyController1 = GameObject.Find("EnemySquad1").GetComponent<Controller>();
     enemyController2 = GameObject.Find("EnemySquad2").GetComponent<Controller>();
     enemyController3 = GameObject.Find("EnemySquad3").GetComponent<Controller>();
     managerText = GameObject.Find("GameManager").GetComponent<GUI_Text>();
 }
Example #9
0
 public void ChangeBarracks(AllyController other)
 {
     barrack = other.barrack;
     ChangeTarget(other);
     if (other.barrack != null)
     {
         other.barrack.Occupy(this);
     }
     availability = false;
 }
Example #10
0
 protected void Start()
 {
     agent = GetComponent <NavMeshAgent>();
     if (target != null)
     {
         SetTarget(target);
     }
     agent.stoppingDistance = interactRadious;
     controller             = GetComponent <AllyController>();
 }
Example #11
0
    public void SetConstruction(Barracks objToConstruct, Transform t)
    {
        AllyController a = GetComponent <AllyController>();

        a.SetPrioirityPoint(t.position);
        constructPosition      = t.position;
        constructionRotation   = t.rotation;
        isBuilding             = true;
        objAssignedToConstruct = objToConstruct;
        home = transform.position;
    }
Example #12
0
    void spawnAlly()
    {
        AllyController a = (AllyController)Instantiate(ally);

        people.Add(a);
        a.gm                 = this;
        a.personName         = "Billy";
        a.transform.position = new Vector3(2, 0, 0);

        a.addWeapon("Pistol");
    }
Example #13
0
 private void handleQuestInput(AllyController a)
 {
     if (questLog.quests.Contains(a.questToGive))
     {
         questLog.turninQuest(a, a.questToGive.getQuestID());
     }
     else
     {
         a.assignQuest(questLog);
     }
 }
Example #14
0
 public void Occupy(AllyController newOccupant)
 {
     if (occupant != null)
     {
         occupant.ChangeBarracks(newOccupant);
     }
     else
     {
         newOccupant.SetPrioirityPoint(GetStandPoint.position);
     }
     occupant = newOccupant;
 }
Example #15
0
    private int ClosestDistanceSort(AllyController x, AllyController y)
    {
        var distancex = Vector3.Distance(x.transform.position, transform.position);
        var distancey = Vector3.Distance(y.transform.position, transform.position);
        if (distancex > distancey)
        {
            return 1;
        }
        else
        {
            return -1;
        }

    }
Example #16
0
 public int getBuildRate()
 {
     if (transform.gameObject.tag == "Ally")
     {
         AllyController ac = transform.GetComponent <AllyController> ();
         return(ac.stats.buildRate);
     }
     else if (transform.gameObject.tag == "Player")
     {
         PlayerController pc = transform.GetComponent <PlayerController> ();
         return(pc.buildRate);
     }
     return(0);
 }
Example #17
0
    public Quest(AllyController _questGiver, QuestObjective _questObjective, int _objectiveID, int _completionAmmount)
    {
        do
        {
            questID = Random.Range(0, 1000);
        } while (idList.Contains(questID));
        Quest.idList.Add(questID);

        questGiver     = _questGiver;
        questObjective = _questObjective;
        Debug.Log("Quest Objective: " + questObjective);
        objectiveID = _objectiveID;
        Debug.Log("ObjectiveID: " + objectiveID);
        completionAmmount = _completionAmmount;
        setName();
    }
Example #18
0
 public void deselectAlly()
 {
     if (selectedAlly != null)
     {
         foreach (GameObject obj in selectedAlly.waypoints)
         {
             obj.SetActive(false);
         }
         selectedAlly = null;
         if (selectRing != null)
         {
             Destroy(selectRing);
         }
         selectRing = null;
     }
 }
Example #19
0
    public bool loadAlly(string[] info)
    {
        if (info.Length < 4)
        {
            return(false);
        }

        AllyController a = (AllyController)Instantiate(ally);

        people.Add(a);
        a.gm                 = this;
        a.personName         = info[0];
        a.transform.position = new Vector3(float.Parse(info[1]), float.Parse(info[2]), 0);
        a.health             = int.Parse(info [3]);

        //Give person starting weapon
        a.addWeapon("Pistol");
        return(true);
    }
Example #20
0
 void getManagerActions()
 {
     if (Input.GetKeyDown(KeyCode.J))
     {
         for (int i = 0; i < spawnAmount; i++)
         {
             spawnEnemy();
         }
     }
     if (Input.GetKeyDown(KeyCode.Space))
     {
         modeIndex    = (modeIndex + 1) % modes.Length;
         playerMode   = modes[modeIndex];
         selectedAlly = null;
         Destroy(selectRing);
         selectRing = null;
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         paused = !paused;
         cam.SetCustomCursor();
     }
 }
Example #21
0
    // Use this for initialization
    void Start()
    {
        ApplicationModel.savePath = Application.streamingAssetsPath + "/saves/";
        mainMenu.gameObject.SetActive(true);
        settingsMenu.gameObject.SetActive(false);
        easyButton   = settingsMenu.transform.Find("Difficulty_Easy").GetComponent <Button> ();
        mediumButton = settingsMenu.transform.Find("Difficulty_Medium").GetComponent <Button> ();
        hardButton   = settingsMenu.transform.Find("Difficulty_Hard").GetComponent <Button> ();
        volumeSlider = settingsMenu.Find("Volume Slider").GetComponent <Slider>();
        loadMenu.gameObject.SetActive(false);
        loadOneButton   = loadMenu.transform.Find("Load_One_Button").GetComponent <Button> ();
        loadTwoButton   = loadMenu.transform.Find("Load_Two_Button").GetComponent <Button> ();
        loadThreeButton = loadMenu.transform.Find("Load_Three_Button").GetComponent <Button> ();
        setDifficultyEasy();

        player            = (PlayerController)Instantiate(player);
        player.gm         = this;
        player.personName = "DummyPlayer";
        personKill.Add(player);

        dummyAlly = (AllyController)Instantiate(ally);
        people.Add(dummyAlly);
        dummyAlly.gm                 = this;
        dummyAlly.personName         = "DummyBilly";
        dummyAlly.transform.position = new Vector3(-6.25f, -1.75f, 0);
        dummyAlly.addWaypoint(new Vector3(-4, 2, 0));
        dummyAlly.addWaypoint(new Vector3(-4, -1.5f, 0));
        dummyAlly.addWaypoint(new Vector3(-8, 0, 0));
        dummyAlly.stats.mode  = "Points";
        dummyAlly.rotationFix = 45.0f;
        foreach (GameObject obj in dummyAlly.waypoints)
        {
            obj.SetActive(false);
        }
        dummyAlly.health = 999999999;
    }
Example #22
0
 void addAlly(AllyController ally)
 {
     allies.Add(ally);
     ally.leader = this;
     ally.mode   = AllyController.Mode.standstill;
 }
Example #23
0
    // Update is called once per frame
    void Update()
    {
        if (!ready)
        {
            return;
        }
        if (paused)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                paused = !paused;
                cam.SetCustomCursor();
                foreach (AllyController a in people)
                {
                    if (a.followingPath)
                    {
                        a.StartCoroutine("FollowPath");
                    }
                }
                foreach (EnemyController e in enemies)
                {
                    if (e.followingPath)
                    {
                        e.StartCoroutine("FollowPath");
                    }
                }
            }
            else
            {
                foreach (AllyController a in people)
                {
                    a.StopCoroutine("FollowPath");
                }
                foreach (EnemyController e in enemies)
                {
                    e.StopCoroutine("FollowPath");
                }
            }
            ui.GMUpdate();
            return;
        }
        updateDayNightCycle();

        spawner.checkSpawnTime();

        //Get Game Actions
        getManagerActions();

        //Update UI
        ui.GMUpdate();

        //Update Player
        player.GMUpdate();

        //Update Camera
        cam.GMUpdate();

        //Update Bullets
        foreach (Bullet b in bullets)
        {
            b.GMUpdate();
            if (b.kill)
            {
                bulletKill.Add(b);
            }
        }

        //Update Enemies
        foreach (EnemyController e in enemies)
        {
            if (getEuclideanDistance(player, e) < 20)
            {
                if (e.interrupted)
                {
                    e.interrupted = false;
                    e.StartCoroutine("FollowPath");
                }
                e.GMUpdate();
                if (e.kill)
                {
                    personKill.Add(e);
                }
            }
            else if (e.followingPath && !e.interrupted)
            {
                e.StopCoroutine("FollowPath");
                e.interrupted = true;
            }
        }

        //Update Allies
        foreach (AllyController a in people)
        {
            a.GMUpdate();
            if (a.kill)
            {
                personKill.Add(a);
            }
            recheckPaths = false;
        }

        //Updated selectedAlly
        if (selectedAlly != null)
        {
            if (selectRing == null)
            {
                string load = "Other/SelectRing";
                selectRing = (GameObject)Instantiate(Resources.Load(load, typeof(GameObject)) as GameObject);
                foreach (GameObject obj in selectedAlly.waypoints)
                {
                    obj.SetActive(true);
                }
            }
            selectRing.transform.position = new Vector3(selectedAlly.transform.position.x, selectedAlly.transform.position.y, 0);
        }

        //Update Buildings
        foreach (Building b in buildings)
        {
            b.GMUpdate();
            if (b.kill)
            {
                buildingKill.Add(b);
            }
        }

        //Update Spawn Pylons
        foreach (SpawnPylon p in pylons)
        {
            p.GMUpdate();
            if (p.kill)
            {
                pylonKill.Add(p);
            }
        }

        //Destroy each object in the kill list and clear it
        foreach (PersonController p in personKill)
        {
            PathRequestManager.RemoveRequest(p);
            if (p.gameObject.tag == "Enemy")
            {
                enemies.Remove((EnemyController)p);
                if (targetedEnemies.IndexOf((EnemyController)p) >= 0)
                {
                    targetedEnemies.Remove((EnemyController)p);
                }
            }
            else if (p.gameObject.tag == "Ally")
            {
                people.Remove((AllyController)p);
                if (p == selectedAlly)
                {
                    selectedAlly = null;
                    Destroy(selectRing);
                    selectRing = null;
                }
            }
            foreach (PersonController other in p.othersInfluenced)
            {
                if (other.gameObject.tag == "Enemy")
                {
                    EnemyController temp = (EnemyController)other;
                    temp.stats.proximityAllies.Remove(p);
                    temp.stats.proximityEnemies.Remove(p);
                    temp.stats.proximityNPCs.Remove(p);
                }
                else if (other.gameObject.tag == "Ally")
                {
                    AllyController temp = (AllyController)other;
                    temp.stats.proximityAllies.Remove(p);
                    temp.stats.proximityEnemies.Remove(p);
                    temp.stats.proximityNPCs.Remove(p);
                }
            }
            p.StopCoroutine("FollowPath");
            Destroy(p.gameObject);
        }
        personKill.Clear();

        //Destroy buildings in kill list and clear it
        foreach (Building b in buildingKill)
        {
            buildings.Remove(b);
            Destroy(b.gameObject);
        }
        buildingKill.Clear();

        //Destroy pylons in kill list and clear it
        foreach (SpawnPylon p in pylonKill)
        {
            pylons.Remove(p);
            Destroy(p.gameObject);
        }
        pylonKill.Clear();

        //Destroy bullets in kill list and clear it
        foreach (Bullet b in bulletKill)
        {
            bullets.Remove(b);
            Destroy(b.gameObject);
        }
        bulletKill.Clear();
    }
Example #24
0
 public void addAlly(AllyController ally)
 {
     allies.Add(ally);
     ally.leader     = this;
     ally.stats.mode = "Standstill";
 }
Example #25
0
 void removeAlly(AllyController ally)
 {
     allies.Remove(ally);
 }
Example #26
0
 public void DesOccupy()
 {
     occupant = null;
 }
Example #27
0
    void getActions()
    {
        if (gm.playerMode == "Combat")           //Get actions for Combat mode
        //Changing Weapons
        {
            if (Input.GetKeyDown(KeyCode.Alpha1) && weapons.Count > 0 && currentWeapon != 0)
            {
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = 0;
                gm.ui.selectWeapon(0);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2) && weapons.Count > 1 && currentWeapon != 1)
            {
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = 1;
                gm.ui.selectWeapon(1);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3) && weapons.Count > 2 && currentWeapon != 2)
            {
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = 2;
                gm.ui.selectWeapon(2);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha4) && weapons.Count > 3 && currentWeapon != 3)
            {
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = 3;
                gm.ui.selectWeapon(3);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha5) && weapons.Count > 4 && currentWeapon != 4)
            {
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = 4;
                gm.ui.selectWeapon(4);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha6) && weapons.Count > 5 && currentWeapon != 5)
            {
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = 5;
                gm.ui.selectWeapon(5);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Q) && weapons.Count > 1)
            {
                //Select previous weapon
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = (currentWeapon - 1);
                if (currentWeapon < 0)
                {
                    currentWeapon = weapons.Count - 1;
                }
                gm.ui.selectWeapon(currentWeapon);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.E) && weapons.Count > 1)
            {
                //Select next weapon
                reloading = false;
                weapons [currentWeapon].SendMessage("interruptReload");
                currentWeapon = (currentWeapon + 1) % weapons.Count;
                gm.ui.selectWeapon(currentWeapon);
                return;
            }
            if (!reloading)
            {
                if (Input.GetMouseButton(0))
                {
                    fireWeapon();
                }
                else
                {
                    if (attackTimer < weapons [currentWeapon].fireRate)
                    {
                        attackTimer += Time.deltaTime;
                    }
                    else
                    {
                        attackTimer = weapons [currentWeapon].fireRate;
                    }
                }

                if ((Input.GetKeyDown(KeyCode.R) || (Input.GetMouseButton(0) && weapons [currentWeapon].currentLoaded == 0)) &&
                    (weapons [currentWeapon].ammoPool > 0 || weapons [currentWeapon].ammoPool == -1) &&
                    weapons[currentWeapon].currentLoaded != weapons[currentWeapon].clipSize &&
                    weapons [currentWeapon].clipSize != -1)
                {
                    reloading = true;
                }
            }
            else
            {
                if (Input.GetMouseButton(0) && weapons [currentWeapon].currentLoaded > 0)
                {
                    reloading = false;
                    weapons [currentWeapon].SendMessage("interruptReload");
                    fireWeapon();
                }
            }
            if (Input.GetMouseButtonDown(1))                //Player right-clicks in Combat mode
            {
                GameObject obj = gm.getClickedObject(2);
                if (obj != null)
                {
                    if (obj.tag == "Enemy")
                    {
                        //Target enemy
                        Debug.Log("Enemy targeted");
                        gm.targetEnemy(obj.GetComponent <EnemyController> ());
                    }
                }
            }
        }
        else if (gm.playerMode == "Command")             //Get actions for Command mode
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (gm.setWaypoints && gm.selectedAlly != null)
                {
                    Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    gm.selectedAlly.addWaypoint(mousePos);
                }
                else
                {
                    GameObject obj = gm.getClickedObject(0);
                    if (obj != null)
                    {
                        if (obj.tag == "Ally")
                        {
                            gm.selectedAlly = obj.GetComponent <AllyController> ();
                        }
                        else if (!EventSystem.current.IsPointerOverGameObject())
                        {
                            gm.deselectAlly();
                        }
                    }
                    else if (!EventSystem.current.IsPointerOverGameObject())
                    {
                        gm.deselectAlly();
                    }
                }
            }
            else if (Input.GetMouseButtonDown(1))
            {
                if (gm.selectedAlly != null)
                {
                    if (gm.setWaypoints)
                    {
                        Debug.Log("Removing waypoint");
                        GameObject obj = gm.getClickedObject(0);
                        if (obj != null)
                        {
                            if (obj.tag == "Waypoint")
                            {
                                gm.selectedAlly.movePoints.Remove(obj.transform.position);
                                Destroy(obj);
                            }
                        }
                    }
                    else
                    {
                        gm.selectedAlly.commandMove(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.Q) && gm.selectedAlly != null)
            {
                gm.selectedAlly.removeLastWaypoint();
            }
            else if (Input.GetKeyDown(KeyCode.E) && gm.selectedAlly != null)
            {
                gm.toggleWaypoints();
            }
        }
        else if (gm.playerMode == "Build")             //Get actions for Build mode
        //Will Change Building according to UI Building Tier selected in the dropdown
        {
            if (Input.GetKeyDown(KeyCode.Alpha1) && buildingSelected != 1)
            {
                gm.ui.forceBuildingChange(0);
                checkMaterials = true;
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2) && buildingSelected != 2)
            {
                gm.ui.forceBuildingChange(1);
                checkMaterials = true;
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3) && buildingSelected != 3)
            {
                gm.ui.forceBuildingChange(2);
                checkMaterials = true;
                return;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha4) && buildingSelected != 4)
            {
                gm.ui.forceBuildingChange(3);
                checkMaterials = true;
                return;
            }

            if (gm.devMode)
            {
                if (Input.GetKeyDown(KeyCode.U))
                {
                    playerInventory ["cloth"]++;
                    checkMaterials = true;
                }
                if (Input.GetKeyDown(KeyCode.I))
                {
                    playerInventory ["wood"]++;
                    checkMaterials = true;
                }
                if (Input.GetKeyDown(KeyCode.O))
                {
                    playerInventory ["stone"]++;
                    checkMaterials = true;
                }
                if (Input.GetKeyDown(KeyCode.P))
                {
                    playerInventory ["metal"]++;
                    checkMaterials = true;
                }
            }

            if (Input.GetKeyDown(KeyCode.R))
            {
                buildingRotation = !buildingRotation;
            }
            if (Input.GetKeyDown(KeyCode.E) || (gm.build && Input.GetMouseButtonDown(1)))
            {
                gm.toggleBuild(false);
            }
            if (Input.GetKeyDown(KeyCode.Q))
            {
                gm.toggleBuildDestroy();
            }

            if (checkMaterials)
            {
                enoughMaterials = false;
                Building temp = null;
                switch (buildingSelected)
                {
                case 1:
                    temp = Resources.Load("Buildings/Tier1Wall", typeof(Building)) as Building;
                    break;

                case 2:
                    temp = Resources.Load("Buildings/Tier2Wall", typeof(Building)) as Building;
                    break;

                case 3:
                    temp = Resources.Load("Buildings/Tier3Wall", typeof(Building)) as Building;
                    break;

                case 4:
                    temp = Resources.Load("Buildings/Toolbench", typeof(Building)) as Building;
                    break;
                }
                enoughMaterials = checkBuildingMaterials(temp);
                checkMaterials  = false;
            }


            if (gm.build && Input.GetMouseButtonDown(0) && gm.ui.pd.checkPlacement())
            {
                Vector3 mousePos     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                string  loadBuilding = "Buildings/";
                switch (buildingSelected)
                {
                case 1:
                    loadBuilding += "Tier1Wall";
                    break;

                case 2:
                    loadBuilding += "Tier2Wall";
                    break;

                case 3:
                    loadBuilding += "Tier3Wall";
                    break;

                case 4:
                    loadBuilding += "Toolbench";
                    break;
                }

                Building newBuilding = Resources.Load(loadBuilding, typeof(Building)) as Building;
                newBuilding = (Building)Instantiate(newBuilding, new Vector3(mousePos.x, mousePos.y, 0),
                                                    Quaternion.LookRotation(Vector3.forward, mousePos - transform.position));
                newBuilding.gm = gm;
                gm.buildings.Add(newBuilding);
                if (buildingRotation)
                {
                    newBuilding.transform.Rotate(new Vector3(0, 0, 90.0f));
                }
                gm.toggleBuild(true);

                //Clear resources that have been consumed
                spendMaterials(newBuilding);
                checkMaterials = true;
            }

            if (gm.buildDestroy && Input.GetMouseButtonDown(0))
            {
                GameObject obj = gm.getClickedObject(1);
                if (obj != null)
                {
                    if (obj.tag == "Building")
                    {
                        gm.buildings.Remove((Building)obj.GetComponent <Building>());
                        Destroy(obj);
                        gm.recreateGrid();
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            AllyController a = getMeleeAlly();
            if (a != null)
            {
                handleQuestInput(a);
            }
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            printQuestLog();
        }
    }
Example #28
0
 public void setController(GameObject inControllerGO)
 {
     flockController = inControllerGO.GetComponent<AllyController>();
 }
Example #29
0
 void Start()
 {
     ship = GetComponentInParent <AllyController>();
 }
 private static void AllyDoesAction(HandleTurn currentActor)
 {
     AllyController currentAlly = currentActor.Attacker.GetComponent <AllyController>();
     //currentAlly.CurrentAllyState = AllyController.AllyState.ACTION;
     //currentAlly.EnemyToAttack = currentActor.Target;
 }
Example #31
0
    // Update is called once per frame
    void Update()
    {
        //Update Enemies
        foreach (EnemyController e in enemies)
        {
            e.GMUpdate();
            if (e.kill)
            {
                personKill.Add(e);
            }
        }

        //Update Ally
        if (dummyAlly != null)
        {
            dummyAlly.GMUpdate();
            if (dummyAlly.kill)
            {
                personKill.Add(dummyAlly);
            }
        }

        //Destroy each object in the kill list and clear it
        foreach (PersonController p in personKill)
        {
            PathRequestManager.RemoveRequest(p);
            if (p.gameObject.tag == "Enemy")
            {
                enemies.Remove((EnemyController)p);
            }
            else if (p.gameObject.tag == "Ally")
            {
                dummyAlly = null;
            }
            Destroy(p.gameObject);
        }
        personKill.Clear();

        //Update Bullets
        foreach (Bullet b in bullets)
        {
            b.GMUpdate();
            if (b.kill)
            {
                bulletKill.Add(b);
            }
        }
        foreach (Bullet b in bulletKill)
        {
            bullets.Remove(b);
            Destroy(b.gameObject);
        }
        bulletKill.Clear();

        spawnTimer += Time.deltaTime;
        if (spawnTimer >= spawnTime)
        {
            spawnTimer = 0.0f;

            spawnEnemyAtLocation(new Vector3(Random.Range(15.0f, 20.0f), Random.Range(-5.0f, 5.0f), 0));
        }
    }
Example #32
0
        private void Start()
        {
            playermovement = GetComponent <Player_Movement>();
            allyController = GetComponent <AllyController>();
            weaponManager  = GetComponent <WeaponManager>();

            originMainPose = weaponManager.m_MainWeaponObject.transform.localPosition;
            originMainRot  = weaponManager.m_MainWeaponObject.transform.localRotation.eulerAngles;

            originSubPose = weaponManager.m_SubWeaponObject.transform.localPosition;
            originSubRot  = weaponManager.m_SubWeaponObject.transform.localRotation.eulerAngles;


            if (playermovement != null)
            {
                switch (playermovement.p_Wstate)
                {
                case WEAPON_STATE.MAIN_WEAPON:
                    weaponManager.m_SubWeaponObject.transform.SetParent(Pose_SubWeapon.transform);
                    weaponManager.m_SubWeaponObject.transform.localPosition = Vector3.zero;
                    weaponManager.m_SubWeaponObject.transform.localRotation = Quaternion.Euler(Vector3.zero);
                    break;

                case WEAPON_STATE.SUB_WEAPON:
                    weaponManager.m_MainWeaponObject.transform.SetParent(Pose_MainWeapon.transform);
                    weaponManager.m_MainWeaponObject.transform.localPosition = Vector3.zero;
                    weaponManager.m_MainWeaponObject.transform.localRotation = Quaternion.Euler(Vector3.zero);
                    break;
                }
            }

            else if (allyController != null)
            {
                if (allyController.weaponType == WeaponType.MainWeapon)
                {
                    weaponManager.m_SubWeaponObject.transform.SetParent(Pose_SubWeapon.transform);
                    weaponManager.m_SubWeaponObject.transform.localPosition = Vector3.zero;
                    weaponManager.m_SubWeaponObject.transform.localRotation = Quaternion.Euler(Vector3.zero);
                }
                else
                {
                    weaponManager.m_MainWeaponObject.transform.SetParent(Pose_MainWeapon.transform);
                    weaponManager.m_MainWeaponObject.transform.localPosition = Vector3.zero;
                    weaponManager.m_MainWeaponObject.transform.localRotation = Quaternion.Euler(Vector3.zero);
                }
            }

            //weaponManager.m_MainWeaponObject.SetActive(true);
            //weaponManager.m_SubWeaponObject.SetActive(true);

            Bomb = Resources.Load("Character/Skill/Bomb") as GameObject;
            int count;

            if (weaponManager.m_MainWeapon == "006" || weaponManager.m_MainWeapon == "008")
            {
                count    = weaponManager.m_MainWeaponObject.transform.childCount - 2;
                main_Mag = weaponManager.m_MainWeaponObject.transform.GetChild(count).gameObject;
            }

            else
            {
                count    = weaponManager.m_MainWeaponObject.transform.childCount - 1;
                main_Mag = weaponManager.m_MainWeaponObject.transform.GetChild(count).gameObject;
            }

            count   = weaponManager.m_SubWeaponObject.transform.childCount - 1;
            sub_Mag = weaponManager.m_SubWeaponObject.transform.GetChild(count).gameObject;

            SettingMag();
        }