Inheritance: MonoBehaviour
Esempio n. 1
0
    private float maxRaycastHitDistance;                                                                        //Max distance a Raycast will hit

    void Start()
    {
        cam = Camera.main;
        maxRaycastHitDistance = 100;
        playerScripts         = player.transform.Find("Scripts").gameObject;
        clickToMove           = playerScripts.GetComponent(typeof(ClickToMove)) as ClickToMove;
    }
Esempio n. 2
0
    private void Start()
    {
        playersInObstructionAtStart = new List <GameObject>();
        playersToRemove             = new List <GameObject>();
        spawnAndTrackItemsScript    = FindObjectOfType <SpawnAndTrackItems>();
        clickToMoveScript           = FindObjectOfType <ClickToMove>();
        playersInBox = new List <GameObject>();


        obstructionCollider    = gameObject.GetComponent <Collider>();
        colliderWidthAndLength = obstructionCollider.bounds.size.x;
        colliderHeight         = obstructionCollider.bounds.size.y;

        colliderHalfExtents = new Vector3(colliderWidthAndLength, colliderHeight, colliderWidthAndLength) / 2;
        Collider[] insideAtStart = Physics.OverlapBox(transform.position, colliderHalfExtents, Quaternion.identity);

        /**
         * For every player that is in the obstruction on instantiation, add them to a List to allow them to walk through the obstruction temporarily.
         * */
        foreach (var collider in insideAtStart)
        {
            //add one collider per player
            if (collider.gameObject.tag.Equals("Player") && !collider.isTrigger)
            {
                playersInObstructionAtStart.Add(collider.gameObject);
            }
        }
    }
Esempio n. 3
0
    public IEnumerator BossScene()
    {
        mob.canMove = false;
        GameObject cam    = GameObject.Find("Main Camera");
        GameObject player = GameObject.Find("Player");

        CameraController.getInstance.StopFollow();
        ClickToMove move = player.GetComponentInChildren <ClickToMove>();

        move.enabled = false;
        Vector3    pos = cam.transform.position;
        Quaternion rot = cam.transform.rotation;

        cam.transform.position = target.transform.position;
        cam.transform.rotation = target.transform.rotation;
        float t = 0f;

        Invoke("PlayParticle", .2f);
        Invoke("SpawnBoss", .7f);
        while (true)
        {
            t += Time.deltaTime;
            if (t > 4)
            {
                cam.transform.position = pos;
                cam.transform.rotation = rot;
                cam.GetComponent <CameraController> ().enabled = true;
                move.enabled = true;
                CameraController.getInstance.Reset();
                mob.canMove = true;
                break;
            }
            yield return(null);
        }
    }
Esempio n. 4
0
 void Awake()
 {
     MainCamera.enabled    = true;
     CookingCamera.enabled = false;
     target     = GameObject.FindGameObjectWithTag("Player");
     flag       = 1;
     moveScript = (ClickToMove)FindObjectOfType(typeof(ClickToMove));
 }
Esempio n. 5
0
	// Use this for initialization
	void Start () {
		this.character = GameObject.FindGameObjectWithTag ("Player");
		this.cm = this.character.GetComponent<ClickToMove> ();
		this.cm2 = this.character.GetComponent<ClickToMove_lvl2> ();
		this.music = GameObject.FindGameObjectWithTag("music_engine").GetComponent<Music_Engine_Script> ();
		destroy = false;
		this.sphere.SetActive(false);
	}
 // Start is called before the first frame update
 void Start()
 {
     myPlayer  = GetComponent <NavMeshAgent>();
     control   = GetComponent <ClickToMove>();
     visual    = GetComponentInChildren <SkinnedMeshRenderer>();
     stepAudio = GetComponentInChildren <AudioSource>();
     footsteps = GetComponentInChildren <FootSteps>();
 }
Esempio n. 7
0
    // Use this for initialization
    void Start()
    {
        m_Agent   = GetComponent <NavMeshAgent>();                       // nav mesh agent
        m_Capsule = GetComponent <CapsuleCollider>();                    //collision

        m_Player           = GameObject.FindGameObjectWithTag("Player"); // player
        m_PlayerMoveScript = m_Player.GetComponent <ClickToMove>();      // player move script

        highlightCircle = GameObject.FindGameObjectWithTag("Highlight"); //highlight game object
        hoverScript     = highlightCircle.GetComponent <Hover>();        //highlight script
    }
Esempio n. 8
0
        /// <summary>Draw the current click to move target.</summary>
        /// <param name="spriteBatch">The sprite batch being drawn.</param>
        public static void DrawClickToMoveTarget(SpriteBatch spriteBatch)
        {
            ClickToMove clickToMove = ClickToMoveManager.GetOrCreate(Game1.currentLocation);

            // Draw click to move target.
            if (clickToMove.TargetNpc is null && (Game1.displayHUD || Game1.eventUp) && Game1.currentBillboard == 0 &&
                Game1.gameMode == Game1.playingGameMode && !Game1.freezeControls && !Game1.panMode &&
                !Game1.HostPaused)
            {
                if (Game1.activeClickableMenu is not null && clickToMove.ClickedTile.X != -1)
                {
                    clickToMove.Reset();
                }
Esempio n. 9
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, Mathf.Infinity, clickableLayer))
            {
                ClickToMove clickedOn = hit.collider.GetComponent <ClickToMove>();
                //if (clickedOn.selected == false)
                //{
                selectedObjects.Add(hit.collider.gameObject);
                lastSelected       = hit.collider.gameObject;
                clickedOn.selected = true;
                //Multi-select
                if (Input.GetKey("left shift"))
                {
                    selectedObjects.Add(hit.collider.gameObject);
                    clickedOn.selected = true;
                }
                else
                {
                    // Select a single object and deselect others
                    foreach (var obj in selectedObjects)
                    {
                        if (!obj.Equals(lastSelected))
                        {
                            obj.GetComponent <ClickToMove>().selected = false;
                        }
                    }
                    selectedObjects.Clear();
                    selectedObjects.Add(lastSelected);
                }
                //}
                //else
                //{
                //    selectedObjects.Add(hit.collider.gameObject);
                //    lastSelected = hit.collider.gameObject;
                //    clickedOn.selected = true;
                //}

                //If you have multiple units selected deselect a single unit that has been clicked on
                if (clickedOn.selected == true && Input.GetKey("left ctrl"))
                {
                    selectedObjects.Remove(hit.collider.gameObject);
                    clickedOn.selected = false;
                }
            }
            DeselectOnGroundClick();
        }
    }
Esempio n. 10
0
	// Use this for initialization
	void Start () {
		//
		this.fireball = Resources.Load<GameObject>("Prefabs/Character_Skills/Fireball_Skill");
		this.warrior_aura = Resources.Load<GameObject>("Prefabs/Character_Skills/Warrior_Aura1");
		this.dagger_shot = Resources.Load<GameObject>("Prefabs/Character_Skills/Daga_skill/Daga_skill");
		
		this.player = GameObject.FindGameObjectWithTag("Player");
		this.cs = this.player.GetComponent<CharacterScript> ();
		this.cm = this.player.GetComponent<ClickToMove> ();
		this.cm2 = this.player.GetComponent<ClickToMove_lvl2> ();

		effect = false;
		actual_time = Time.time;
	}
Esempio n. 11
0
    void Update()
    {
        if (SelectThisUnit == true)
        {
            ClickToMove component = thisUnit.GetComponent <ClickToMove> ();
            component.enabled = true;
            thisUnit.transform.GetChild(0).gameObject.SetActive(true);
        }

        if (SelectThisUnit == false)
        {
            ClickToMove component = thisUnit.GetComponent <ClickToMove> ();
            component.enabled = false;
            thisUnit.transform.GetChild(0).gameObject.SetActive(false);
        }
    }
Esempio n. 12
0
        void Start()
        {
            // Player movement scripts
            click       = player.GetComponent <ClickToMove>();
            directional = player.GetComponent <DirectionalMove>();
            firstPerson = player.GetComponent <FirstPersonMove>();

            // Camera movement scripts
            topDown    = cam.GetComponent <CameraTopDown>();
            topDownPan = cam.GetComponent <CameraTopDownPan>();
            fps        = cam.GetComponent <CameraFirstPerson>();

            // Set variables for initial camera position and rotation
            camPos = cam.transform.position;
            camRot = cam.transform.rotation;
        }
Esempio n. 13
0
 /// <summary>
 ///     Adds the <see cref="GameLocation" /> and associated <see cref="ClickToMove" /> object
 ///     if the game location doesn't exist, or updates the associated object if it does exist.
 /// </summary>
 /// <param name="location"><see cref="GameLocation" /> to add or update. If it's null, nothing is done.</param>
 /// <param name="clickToMove"><see cref="ClickToMove" /> object to associate with the game location.</param>
 public static void AddOrUpdate(GameLocation location, ClickToMove clickToMove)
 {
     if (location is not null)
     {
         // If we found the key we should just update, if no we should create a new entry.
         if (ClickToMoveManager.GameLocations.TryGetValue(location, out ClickToMove _))
         {
             ClickToMoveManager.GameLocations.Remove(location);
             ClickToMoveManager.GameLocations.Add(location, clickToMove);
         }
         else
         {
             ClickToMoveManager.GameLocations.Add(location, clickToMove);
         }
     }
 }
Esempio n. 14
0
    IEnumerator movePath()
    {
        do
        {
            for (int i = (MoveList.Count - 1); i >= 0; i--)
            {
                Debug.Log("Walk to " + MoveList[i].getX() + " ," + MoveList[i].getY());
                yield return(StartCoroutine(movingObj(new Vector3(MoveList[i].getX(), MoveList[i].getY(), 0))));
            }
        } while (hold.transform.position != newLocation && isMoving);
        isMoving = false;
        selected = false;
        ClickToMove ctm = (ClickToMove)hold.GetComponent("ClickToMove");

        ctm.changeColor(selected);
        hold.transform.position = newLocation;
        Debug.Log("Reached End");
    }
Esempio n. 15
0
	// Use this for initialization
	void Start () {

		this.character = GameObject.FindGameObjectWithTag ("Player");
		this.cs = this.character.GetComponent<CharacterScript> ();
		this.cm = this.character.GetComponent<ClickToMove> ();
		//this.cm2 = this.character.GetComponent<ClickToMove_lvl2> ();

		// ADD TEXTURES
		this.actionBarTexture = Resources.Load<Texture2D>("ActionBar/actionbar");

		this.fireballTexture = Resources.Load<Texture2D>("ActionBar/skill_fireball");
		this.reloadFireballTexture = Resources.Load<Texture2D>("ActionBar/reload_fireball");
		this.PowerKnifeTexture = Resources.Load<Texture2D>("ActionBar/skill_powerKnife");
		this.reloadPowerKnifeTexture = Resources.Load<Texture2D>("ActionBar/reload_powerKnife");
		this.DarkAuraTexture = Resources.Load<Texture2D>("ActionBar/skill_aura");
		this.reloadDarkAuraTexture = Resources.Load<Texture2D>("ActionBar/reload_aura");

		this.attackIconTexture = Resources.Load<Texture2D>("ActionBar/icon_attack_v2");
		this.runIconTexture = Resources.Load<Texture2D>("ActionBar/icon_run");
		this.potionIconTexture = Resources.Load<Texture2D>("ActionBar/icon_elixir_v2");
		this.inventoryIconTexture = Resources.Load<Texture2D>("ActionBar/icon_inventory_v2");
		this.mapIconTexture = Resources.Load<Texture2D>("ActionBar/icon_map");

		//Debug.Log (this.actionBarTexture.name);

		inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<InventoryScript> ();

		//this.cs = GameObject.FindGameObjectWithTag ("Player").GetComponent<CharacterScript> ();

		this.text_style = new GUIStyle ();
		this.text_style.normal.textColor = Color.red;
		this.text_style.fontSize = 15;
		this.text_style.alignment = TextAnchor.UpperCenter ; 
		this.text_style.wordWrap = true; 

		disabledSkill1 = false;
		disabledSkill2 = false;
		disabledSkill3 = false;


	}
Esempio n. 16
0
    void Start()
    {
        // שיוך לקנבס של כל דמות
        MarioCanvas   = Mario.GetComponentInChildren <Canvas>();
        PacManCanvas  = PacMan.GetComponentInChildren <Canvas>();
        PikachuCanvas = Pikachu.GetComponentInChildren <Canvas>();
        NurseCanvas   = Nurse.GetComponentInChildren <Canvas>();

        // שיוך לטקסט בקנבס של כל דמות
        MarioText   = Mario.GetComponentInChildren <Text>();
        PacManText  = PacMan.GetComponentInChildren <Text>();
        PikachuText = Pikachu.GetComponentInChildren <Text>();
        NurseText   = Nurse.GetComponentInChildren <Text>();

        // שיוך לאנימטור של כל דמות
        MarioAnimator   = Mario.GetComponentInChildren <Animator>();
        PacManAnimator  = PacMan.GetComponentInChildren <Animator>();
        GhostAnimator   = Ghost.GetComponentInChildren <Animator>();
        PikachuAnimator = Pikachu.GetComponentInChildren <Animator>();

        // של כל דמות NavMeshAgent שיוך ל
        PlayerAgent  = GetComponent <NavMeshAgent>();
        MarioAgent   = Mario.GetComponent <NavMeshAgent>();
        PacManAgent  = PacMan.GetComponent <NavMeshAgent>();
        PikachuAgent = Pikachu.GetComponent <NavMeshAgent>();

        // של כל דמות NavMeshObstacle שיוך ל
        MarioNavMeshObstacle   = Mario.GetComponent <NavMeshObstacle>();
        PacManNavMeshObstacle  = PacMan.GetComponentInChildren <NavMeshObstacle>();
        PikachuNavMeshObstacle = Pikachu.GetComponent <NavMeshObstacle>();

        // יחוס למחלקות אחרות
        CameraController = Camera.main.GetComponent <CameraController>();
        ClickToMove      = GetComponent <ClickToMove>();
        PickDropObject   = GetComponent <PickDropObject>();
        RotateTo         = GetComponent <RotateTo>();

//      StartCoroutine(Test()); // הפעלת פונקציה לבדיקת המשחק
    }
Esempio n. 17
0
    private void OnEnable()
    {
        manage          = GameObject.FindGameObjectWithTag("select").GetComponent <management>();
        slider.maxValue = initial_life;
        myselect        = null;
        GameObject[] select = GameObject.FindGameObjectsWithTag("select");
        int          i;

        for (i = 0; i < select.Length; i++)
        {
            if (select[i].layer == gameObject.layer)
            {
                myselect = select[i];
                break;
            }
        }
        click = this.gameObject.GetComponent <ClickToMove>();
        if (myselect && click)
        {
            myselect.GetComponent <Select>().alltanks.Add(click);
        }
    }
Esempio n. 18
0
	// Use this for initialization
	void Awake () {
		
		// --- LOAD RESOURCES TO CHARACTER ---
		this.prefab = Resources.Load<Transform>("Prefabs/MainCharacters/" + PlayerPrefs.GetString("Player"));
		Instantiate (prefab);
		this.character = GameObject.FindGameObjectWithTag ("Player");
		this.invent = this.character.GetComponentInChildren <InventoryScript> ();
		this.map = GameObject.FindGameObjectWithTag ("Minimap").GetComponent<miniMapLv1> ();
		this.cm = this.character.GetComponent<ClickToMove> ();
		this.cs = this.character.GetComponent<CharacterScript> ();

		// Memory Card Save/Load data
		this.mc = GameObject.FindGameObjectWithTag ("MemoryCard").GetComponent<MemoryCard> ();
		this.save = this.mc.saveData();
		this.load = this.mc.loadData();
		time_play = this.load.loadTimePlayed (); 

		this.npc_boss = GameObject.FindGameObjectWithTag("Boss");
		this.npc_enemy = GameObject.FindGameObjectsWithTag("Enemy");

		this.camera1 = GameObject.FindGameObjectWithTag ("MainCamera");
		this.camera1.SetActive (true);
		
		this.camera2 = GameObject.FindGameObjectWithTag ("CameraGoal");
		this.camera2.SetActive (false);

		this.music = GameObject.FindGameObjectWithTag ("music_engine").GetComponent<Music_Engine_Script> ();

		// --- LOAD RESOURCES TO MENU ---
		gui = new PauseMenuGUI ();
		gui.initResources ();
		
		
		this.c = this.ambientLight.light.color;
		pause = false;

	}
Esempio n. 19
0
    IEnumerator RoundStarting()
    {
        print("Round starting");

        audioManager = FindObjectOfType <AudioManager>();

        if (playIntro)
        {
            yield return(StartCoroutine(TutorialCoroutine()));
        }

        SpawnPlayer();

        isPlayerDead = false;

        playerMove = FindObjectOfType <ClickToMove>();

        if (playerMove == null)
        {
            Debug.LogError("playerMove is Null");

            isPlayerDead = true;
        }

        //        PlayBackgroundMusic();

        //       player.transform.position = playerInitialPosition.position;

        roundEnded = false;

        yield return(new WaitForSeconds(endWaitTime));

        if (RoundStartedEvent != null)
        {
            RoundStartedEvent();
        }
    }
Esempio n. 20
0
	// Use this for initialization
	void Start () {
	
		this.character = PlayerPrefs.GetString ("Player");

		this.list_inventory = new List<Item>();
		this.equip = new Item[5]; //"Weapon, Shield, Helmet, Armor, Boots"
		this.inventoryTexture = Resources.Load<Texture2D>("Inventory/Misc/inventory_" + this.character);
		this.map_lvl1 = GameObject.FindGameObjectWithTag ("Minimap").GetComponent<miniMapLv1> ();
		this.map_lvl2 = GameObject.FindGameObjectWithTag ("Minimap").GetComponent<miniMapLv2> ();
		//this.prueba = Resources.Load<Texture2D>("Inventory/Misc/slot");

		this.cs = GameObject.FindGameObjectWithTag ("Player").GetComponent<CharacterScript> ();
		this.cm = GameObject.FindGameObjectWithTag ("Player").GetComponent<ClickToMove> ();
		this.cm2 = GameObject.FindGameObjectWithTag ("Player").GetComponent<ClickToMove_lvl2> ();

		// Memory Card Save/Load data
		this.mc = GameObject.FindGameObjectWithTag ("MemoryCard").GetComponent<MemoryCard> ();
		this.save = this.mc.saveData();
		this.load = this.mc.loadData();

		// STYLES TEXT
		this.attributes_style = new GUIStyle ();
		//this.text_style.font = Resources.Load<Font>("MainMenu/avqest");
		this.attributes_style.fontStyle = FontStyle.Bold;
		this.attributes_style.normal.textColor = new Color (236f/255f,219f/255f,31f/255f);
		this.attributes_style.fontSize = 20;

		this.exp_style = new GUIStyle ();
		//this.text_style.font = Resources.Load<Font>("MainMenu/avqest");
		this.exp_style.fontStyle = FontStyle.Bold;
		this.exp_style.normal.textColor = new Color (236f/255f,219f/255f,31f/255f);
		this.exp_style.fontSize = 17;

		this.level_style = new GUIStyle ();
		//this.text_style.font = Resources.Load<Font>("MainMenu/avqest");
		this.level_style.fontStyle = FontStyle.Bold;
		this.level_style.normal.textColor = new Color (236f/255f,219f/255f,31f/255f);
		this.level_style.fontSize = 13;

		// CREATE INVENTORY
		this.resizeInventory ();
		this.createInventorySlot ();

		int num = this.load.loadNumItemsInventory ();

		if (num > 0)
			this.load.loadInventoryItems (num);

		this.equip = load.loadEquipItem ();
	}
 // Use this for initialization
 void Awake()
 {
     clicktomove = GetComponent<ClickToMove>();
     currentHealth = startingHealth;
 }
Esempio n. 22
0
    // Update is called once per frame

    void Update()
    {
        if (pointer.selectedObjets == null)
        {
            print("null");
            return;
        }
        else
        {
            foreach (GameObject go in pointer.selectedObjets)
            {
                if (go.name == "worker(Clone)")
                {
                    worker = go;
                    //    buildingsM.gameObject.SetActive(true);
                    inBuilding = true;
                }
            }
        }

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // the ray follows the mousr

        Physics.Raycast(ray, out hit, Mathf.Infinity);


        // temp.z = 10f; // Set this to be the distance you want the object to be placed in front of the camera.

        if (Input.GetKeyDown(KeyCode.B) || canvasButton)
        {
            canvasButton = false;
            Build        = false;
            //   buildingsM.gameObject.SetActive(false);
            pos = Vector3.zero;
        }

        if ((Input.GetKeyDown(KeyCode.T) && inBuilding) || townhallFunc)
        {
            go1 = Instantiate(townHall) as GameObject;
            go1.transform.position = hit.point;
            PaintObjGreen(go1);
            townH = true;

            townhallFunc = false;
        }
        else if ((Input.GetKeyDown(KeyCode.F) && inBuilding) || forgeFunc)
        {
            go1 = Instantiate(Forge) as GameObject;
            go1.transform.position = hit.point;
            PaintObjGreen(go1);
            ForgeB    = true;
            forgeFunc = false;
        }
        else if ((Input.GetKeyDown(KeyCode.U) && inBuilding) || barracksFunc)
        {
            go1 = Instantiate(Barracks) as GameObject;
            go1.transform.position = hit.point;
            PaintObjGreen(go1);
            BarracksB    = true;
            barracksFunc = false;
        }
        else if ((Input.GetKeyDown(KeyCode.S) && inBuilding) || farmFunc)
        {
            go1 = Instantiate(Farm) as GameObject;
            go1.transform.position = hit.point;
            PaintObjGreen(go1);
            FarmB    = true;
            farmFunc = false;
        }
        else if ((Input.GetKeyDown(KeyCode.H) && inBuilding) || stableFunc)
        {
            go1 = Instantiate(Stable) as GameObject;
            go1.transform.position = hit.point;
            PaintObjGreen(go1);
            StableB    = true;
            stableFunc = false;
        }

        if ((inBuilding && !wait) && go1 != null)
        {
            go1.transform.position = hit.point;
            //  Ray ray2 = Camera.main.ScreenPointToRay(Input.mousePosition);
        }
        if (!ready && inBuilding && !worker.GetComponent <Animator>().GetBool("isAttack"))
        {
            if (!ready && Input.GetMouseButtonUp(0) && !clicked)
            {
                pointer.selectedObjets.Add(worker);
                TimeFirstClick = limitToNextClick;

                clicked = true;
            }

            //       RaycastHit2D hit2;

            if (clicked)
            {
                TimeFirstClick -= Time.deltaTime;
            }
            // if (TimeFirstClick != 0)
            // print(TimeFirstClick);



            if (!ready && Input.GetMouseButtonDown(0) && (TimeFirstClick < 0) && worker != null)
            {
                ctm = worker.GetComponent <ClickToMove>();
                //    pointer.selectedObjets.Add(worker);
                pos = hit.point;
                if (ctm != null)
                {
                    ctm.goTo(worker, pos);
                }
                print("im in the funcktion  motha f***a");

                wait  = true;
                Build = true;
                //    ready = true;
                clicked = false;
                //   if(ctm!=null&&worker!=null)
                // ctm.goTo(worker, pos);
                TimeFirstClick = 0.5f;
                //     ready = true;
            }

            //   if (hit2 = Physics2D.Raycast(ray2.origin, new Vector2(0, 0)))
            //      Debug.Log(hit2.collider.name);

            //    if (hit2.collider.name != "BuildM")
            //       print("NULLLLLLLLLL");
            //

            // Input.GetMouseButtonUp(0) && Physics2D.Raycast(ray2.origin, new Vector2(0, 0)).collider == null

            if (!ready && ctm.stopUnits(worker.transform.position, 0) && Build && worker != null)
            {
                ctm = worker.GetComponent <ClickToMove>();
                ctm.stopUnit(worker);
                worker.GetComponent <Animator>().SetBool("isWalking", false);
                worker.GetComponent <Animator>().SetBool("isAttack", true);
                worker.GetComponent <ClickToMove>().enabled = false;
                ready = true;
                pointer.selectedObjets.Add(worker);
            }

            //  buildingsM.gameObject.SetActive(false);

            /*      pos = hit.point;
             *       go1.transform.position = pos;
             *
             *       wait = true;
             *       Build = false;
             * //    Build = true; // to change the worker walking to the building here
             *   }
             *
             * //      if (Build&&wait)
             * //.   {*/

            if (ready)
            {
                if (!worker.GetComponent <Animator>().GetBool("isAttack"))
                {
                    worker.GetComponent <Animator>().SetBool("isWalking", false);
                    worker.GetComponent <Animator>().SetBool("isAttack", true);
                }
                pointer.selectedObjets.Add(worker);
                inBuilding = false;
                ready      = false;
                clicked    = false;
                Build      = false;
                wait       = false;
                inCreate   = false;
                if (pos != Vector3.zero)
                {
                    Destroy(go1);

                    if (townH)
                    {
                        c     = Instantiate(townHall, pos, transform.rotation) as GameObject;
                        townH = false;
                    }
                    else if (ForgeB)
                    {
                        c      = Instantiate(Forge, pos, transform.rotation) as GameObject;
                        ForgeB = false;
                    }
                    else if (BarracksB)
                    {
                        c         = Instantiate(Barracks, pos, transform.rotation) as GameObject;
                        BarracksB = false;
                    }
                    else if (FarmB)
                    {
                        c     = Instantiate(Farm, pos, transform.rotation) as GameObject;
                        FarmB = false;
                    }
                    else if (StableB)
                    {
                        c       = Instantiate(Stable, pos, transform.rotation) as GameObject;
                        StableB = false;
                    }
                    Unit u = new Unit();
                    u.go  = c;
                    u.pos = c.transform.position;
                    u.id  = Client.getMyBuildingId();

                    Client.incBuildingID();
                    myBuildings.Add(c);
                    Build = false;
                    wait  = false;
                    c.GetComponent <KeepHere>().worker   = worker;
                    c.GetComponent <KeepHere>().enabled  = true;
                    c.GetComponent <KeepHere>().fromFunc = true;
                    c.GetComponent <unit>().clientId     = 1;
                    c.transform.Find("particles").gameObject.SetActive(true);
                    this.GetComponent <Client>().SendBuildingUpdate(c.name, pos, transform.rotation.y, Client.getMyConId());
                    Client.getMyplayerHandler().myBuildings.Add(u);
                    inBuilding = false;
                    worker     = null;
                    pos        = Vector3.zero;
                }
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            TimeFirstClick = 0.5f;
            wait           = false;
            ready          = false;
            clicked        = false;
            Build          = false;
            inBuilding     = false;
            StableB        = false;
            FarmB          = false;
            inBuilding     = false;
            townH          = false;
            BarracksB      = false;
            ForgeB         = false;
            Destroy(go1);
        }
    }
Esempio n. 23
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && clickobject.if_a())
        {
            drawpoint1    = Input.mousePosition;
            point1        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            if_draw       = true;
            select_target = Physics2D.OverlapCircle(point1, enemy_select_radius);
            point2        = point1;
        }
        if (Input.GetMouseButton(0))
        {
            drawpoint2 = Input.mousePosition;
            point2     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        }
        if (Input.GetMouseButtonUp(0))
        {
            if_draw = false;
        }

        if (point1 != point2)
        {
            if (point1 != oldpoint1 || point2 != oldpoint2)
            {
                first = -1;
                for (int i = 0; i < alltanks.Count; i++)
                {
                    Vector2 position = alltanks[i].GetComponent <Rigidbody2D>().transform.position;
                    alltanks[i].select = false;
                    if (((position.x < point1.x) && (position.x > point2.x)) || ((position.x > point1.x) && (position.x < point2.x)))
                    {
                        if (((position.y < point1.y) && (position.y > point2.y)) || ((position.y > point1.y) && (position.y < point2.y)))
                        {
                            first = i;
                            alltanks[i].select = true;
                        }
                    }
                }
            }
        }
        else
        {
            first = -1;
            for (int i = 0; i < alltanks.Count; i++)
            {
                alltanks[i].select = false;
            }
            if (select_target && (select_target.gameObject.layer == gameObject.layer))
            {
                y = select_target.GetComponent <ClickToMove>();
                if (y)
                {
                    y.select = true;
                }
                first = -1;
                for (int i = 0; i < alltanks.Count; i++)
                {
                    if (alltanks[i].select)
                    {
                        first = i;
                        break;
                    }
                }
            }
        }
        oldpoint1 = point1;
        oldpoint2 = point2;
        if (first != -1)
        {
            select_target = alltanks[first].GetComponent <Collider2D>();
        }
    }
 public static void Face(Vector3 to, float addRadian = 0)
 {
     ClickToMove.CGPlayer_C__ClickToMove(0, 0, 0, ObjectManager.Me.Guid, (int)ClickToMoveType.Face, (float)System.Math.Atan2(to.Y - ObjectManager.Me.Position.Y, to.X - ObjectManager.Me.Position.X) + addRadian);
     //Lua.LuaDoString("TurnLeftStart(); TurnLeftStop();");
     //Lua.LuaDoString("TurnRightStart(); TurnRightStop();");
 }
Esempio n. 25
0
 void OnDestroy()
 {
     instance = null;
 }
 /*
  * with vsync turned on, this function errors for some reason - without vsync on, the Lua turning part gets ignore (which was supposed to nudge the character so the server recognizes changed movement)
  */
 public static void FaceUnit(WoWUnit unit)
 {
     ClickToMove.CGPlayer_C__ClickToMove(unit.Position.X, unit.Position.Y, unit.Position.Z, unit.Guid, (int)ClickToMoveType.Face, 0.5f);
     //Lua.LuaDoString("TurnLeftStart(); TurnLeftStop();");
     //Lua.LuaDoString("TurnRightStart(); TurnRightStop();");
 }
 // Use this for initialization
 void Awake()
 {
     clicktomove   = GetComponent <ClickToMove>();
     currentHealth = startingHealth;
 }
Esempio n. 28
0
 // Use this for initialization
 void Awake()
 {
     characterProperty = GetComponent <CharacterProperty> ();
     clickToMove       = gameObject.GetComponent <ClickToMove> ();
 }
Esempio n. 29
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButton("Fire1") && Time.time > nextFire)            // Nextfire intentionally to prevent multiple calls in one click
        {
            nextFire = Time.time + 0.5f;

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (isMoving)
            {
                Debug.Log("Wait until move finishes.");
                return;
            }

            if (Physics.Raycast(ray, out hit, 1000f)) //From camera, pick the frontmost object shown on screen, output object into hit
            {                                         //using contitionals to determine what to do with this object we just hit with our click
                if (hit.transform.tag == "Units" && selected == false)
                {
                    hold     = hit.transform.gameObject;
                    selected = true;
                    ClickToMove ctm = (ClickToMove)hold.GetComponent("ClickToMove");
                    ctm.changeColor(selected);
                    Pathfinder.highlightMoveable(floorWeight, hold.transform.position, ctm.getMaxMove());
                }
                else if (hit.transform.tag == "Units" && selected == true)              //action should change, part of next stage
                {
                    selected = false;
                    ClickToMove ctm = (ClickToMove)hold.GetComponent("ClickToMove");
                    ctm.changeColor(selected);
                    hold = null;
                    Pathfinder.colourMoveable(selected);
                }
                else if (hit.transform.tag == "Floor" && selected == true && hit.transform.gameObject.renderer.material.color == Color.cyan)
                {
                    Pathfinder.colourMoveable(false);
                    if (isMoving)
                    {
                        Debug.Log("Wait until move finishes.");
                        return;
                    }

                    newLocation   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    newLocation.z = 0;
                    newLocation.x = Mathf.Round(newLocation.x);
                    newLocation.y = Mathf.Round(newLocation.y);
                    //Debug.Log (floorWeight [(int)newLocation.y] [(int)newLocation.x]);
                    Debug.Log("You are at " + hold.transform.position.x + "," + hold.transform.position.y);
                    Debug.Log("You clicked on " + newLocation.x + "," + newLocation.y);

                    if (floorWeight[(int)newLocation.y][(int)newLocation.x] != 0)
                    {
                        Pathfinder.findPath(floorWeight, hold.transform.position, newLocation);
                        moveToIt();
                    }
                    else
                    {
                        Debug.Log("This spot is unreachable");
                    }
                }
                else
                {
                    selected = false;
                    ClickToMove ctm = (ClickToMove)hold.GetComponent("ClickToMove");
                    ctm.changeColor(selected);
                    hold = null;
                    Pathfinder.colourMoveable(selected);
                }
            }
        }
    }
Esempio n. 30
0
 protected override void Awake()
 {
     base.Awake();
     clickToMove = FindObjectOfType <ClickToMove>();
 }
Esempio n. 31
0
    //--------------------------------------
    #endregion

    #region Unity's Method
    //--------------------------------------

    void Awake()
    {
        m_clickToMove = GetComponent <ClickToMove>();
    }
Esempio n. 32
0
 public void Awake()
 {
     instance = this;
 }
Esempio n. 33
0
 private void Start()
 {
     clickToMove = GameObject.FindGameObjectWithTag(characterControllerTagName).GetComponent <ClickToMove>();
 }
Esempio n. 34
0
 // Use this for initialization
 void Awake()
 {
     clickToMove = player.GetComponent <ClickToMove> ();
 }
Esempio n. 35
0
 void Start()
 {
     clickToMove = FindObjectOfType <Player>().gameObject.GetComponent <ClickToMove>();
 }
Esempio n. 36
0
 void Start()
 {
     anim        = GetComponent <Animator>();
     ClickToMove = GetComponent <ClickToMove>();
     RotateTo    = GetComponent <RotateTo>();
 }