示例#1
0
 void Start()
 {
     player  = GetComponent <Player>();
     boxRect = selectionBox.GetComponent <RectTransform>();
     selectionBox.SetActive(false);
     cameraController = FindObjectOfType <RTSCamera>();
 }
示例#2
0
 // Use this for initialization
 void Start()
 {
     selected = false;
     camera   = GameObject.Find("Main Camera").GetComponent <RTSCamera>();
     rb       = GetComponent <Rigidbody> ();
     if (name == "Rhino")
     {
         fireLocation = transform.Find("medium 1").Find("mediumvehicle_gun").Find("gunmount").Find("gun_fx_mount");
         gun          = transform.Find("medium 1").Find("mediumvehicle_gun").Find("gunmount");
     }
     moving          = false;
     invalidPosition = new Vector3(-99999, -99999, -99999);
     if (!building)
     {
         nav = GetComponent <NavMeshAgent> ();
         nav.updateRotation = true;
     }
     anim = GetComponentInChildren <Animator> ();
     if (team == 2)
     {
         gameObject.GetComponentInChildren <Renderer>().material = enemyMat;
         gameObject.tag = "Enemy";
     }
     targetSearchTimer = 0f;
     target            = null; //<null if there is no target in range
     reloadTimer       = 0f;
 }
示例#3
0
    public void InitializeSettings()
    {
        camera = Camera.main.GetComponent<RTSCamera>();

        int invertPan = PlayerPrefs.GetInt(CameraSettings.Instance.RTS_INVERT_PAN);
        if (invertPan == 1)
            invertPanField.isOn = true;
        else
            invertPanField.isOn = false;
        panSmoothField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_PAN_SMOOTH);
        panInputField.text = PlayerPrefs.GetString(CameraSettings.Instance.RTS_PAN_INPUT);
        distanceField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_DISTANCE);
        int allowZoom = PlayerPrefs.GetInt(CameraSettings.Instance.RTS_ALLOW_ZOOM);
        if (allowZoom == 1)
            allowZoomField.isOn = true;
        else
            allowZoomField.isOn = false;
        zoomSmoothField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_ZOOM_SMOOTH);
        zoomStepField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_ZOOM_STEP);
        maxZoomField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_MAX_ZOOM);
        minZoomField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_MIN_ZOOM);

        xRotationField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_X_ROTATION);
        yOrbitSmoothField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_Y_ORBIT_SMOOTH);
        int allowOrbit = PlayerPrefs.GetInt(CameraSettings.Instance.RTS_ALLOW_ORBIT);
        if (allowOrbit == 1)
            allowOrbitField.isOn = true;
        else
            allowOrbitField.isOn = false;
        orbitInputField.text = PlayerPrefs.GetString(CameraSettings.Instance.RTS_ORBIT_INPUT);

    }
示例#4
0
        protected override void OnStart()
        {
            if (this.Mine)
            {
                //Setup
                this.Units = Array.AsReadOnly(this.units);
                this.visibleSandpit.Visible = true;
                Camera    cam    = Camera.main;
                RTSCamera rtsCam = cam.GetComponent <RTSCamera>();
                Transform parent = cam.transform.parent;
                cam.orthographicSize = 15;
                parent.position      = this.startCameraPosition;
                parent.rotation      = Quaternion.Euler(this.startCameraRotation);
                rtsCam.enabled       = true;
                GameEvents.OnUnitRemovedFromQueue.AddListener(OnUnitRemovedFromQueue);

                //Create a farmer
                Unit farmer = this.units[5];
                if (PhotonNetwork.IsConnected)
                {
                    GameObject go = PhotonNetwork.Instantiate(farmer.name, this.spawnLocation.position, farmer.transform.rotation);
                    go.transform.SetParent(this.transform.parent, true);
                    Unit u = go.GetComponent <Unit>();
                    u.MoveUnit(u.Position + this.transform.forward * 2f, u.Position);
                    GameEvents.OnUnitCreated.Invoke(go.GetComponent <Unit>());
                }
                else
                {
                    Unit u = Instantiate(farmer, this.spawnLocation.position + Vector3.forward * 2f, farmer.transform.rotation, this.transform.parent);
                    u.MoveUnit(u.Position + this.transform.forward, u.Position);
                    GameEvents.OnUnitCreated.Invoke(u);
                }
            }
        }
示例#5
0
 void Start()
 {
     rtsCamera    = Camera.main.GetComponent <RTSCamera>();
     outline      = Camera.main.GetComponent <RenderBlurOutline>();
     aiFreeBattle = transform.Find("AIFreeBattle").GetComponent <AIFreeBattle>();
     preloadDrama();
 }
示例#6
0
    void Start()
    {
        standard = GetComponent<StandardCamera>();
        topDown = GetComponent<TopDownCamera>();
        rts = GetComponent<RTSCamera>();

        //SwitchToStandard();
    }
示例#7
0
    void Start()
    {
        standard = GetComponent <StandardCamera>();
        topDown  = GetComponent <TopDownCamera>();
        rts      = GetComponent <RTSCamera>();

        SwitchToStandard();
    }
示例#8
0
	void Awake () 
	{
		if (instance == null)
			instance = this;

		newPosition = contextMenu.position;
		rtsCamera = Camera.main.GetComponent<RTSCamera> ();
	}
示例#9
0
 /// <summary>
 ///
 /// </summary>
 public override void Draw(RTSCamera camera)
 {
     // TODO: Add your drawing code here
     CopyMatrix(camera);
     DrawModel(tankBody, tankTexture, tankBodyTransform);
     DrawModel(tankTurret, tankTexture, tankTurretTransform);
     DrawModel(tankBarrel, tankTexture, tankBarrelTransform);
 }
    void Start()
    {
        clientNetworkManager = ClientNetworkManager.Instance;
        clientGameManager    = ClientGameManager.Instance;
        clientEntityManager  = ClientEntityManager.Instance;
        uiManager            = UIManager.Instance;

        rtsCamera = FindObjectOfType <RTSCamera>();
    }
示例#11
0
    public void GenerateMap(MapSize mapSize)
    {
        mapGrid.Create(mapSize.x, mapSize.y);
        RTSCamera cam = Camera.main.GetComponent <RTSCamera>();

        cam.minY     = mapSize.minScrollY;
        cam.maxY     = mapSize.maxScrollY;
        cam.panLimit = mapSize.panLimit;
    }
示例#12
0
 public void Init()
 {
     Profiler.maxNumberOfSamplesPerFrame = -1;
     standard = Camera.main.GetComponent<StandardCamera>();
     topDown = Camera.main.GetComponent<TopDownCamera>();
     rts = Camera.main.GetComponent<RTSCamera>();
     fps = Camera.main.GetComponent<FPSCamera>();
     
     SwitchToCamera(PlayerPrefs.GetInt(CameraSettings.Instance.CAMERA_TYPE));
 }
示例#13
0
    public void Init()
    {
        Profiler.maxNumberOfSamplesPerFrame = -1;
        standard = Camera.main.GetComponent <StandardCamera>();
        topDown  = Camera.main.GetComponent <TopDownCamera>();
        rts      = Camera.main.GetComponent <RTSCamera>();
        fps      = Camera.main.GetComponent <FPSCamera>();

        SwitchToCamera(PlayerPrefs.GetInt(CameraSettings.Instance.CAMERA_TYPE));
    }
示例#14
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            rand = new Random();
            // TODO: Add your initialization logic here
            floor  = new Box(0, 0, 0, worldSize, 1, worldSize);
            camera = new RTSCamera(this, new Vector3(0, 560, 0), 5, -10);


            reset();
            base.Initialize();
        }
示例#15
0
    internal IEnumerator ActivateAITree(Unit _aiUnit)
    {
        aiUnit    = _aiUnit;
        rtsCamera = Camera.main.GetComponent <RTSCamera>();
        outline   = Camera.main.GetComponent <RenderBlurOutline>();

        //create move Range and Delete() it after AINodeMoveAI
        moveRange = new MoveRange();
        moveRange.CreateMoveRange(aiUnit.transform);

        yield return(StartCoroutine(ActionNode(root)));
    }
示例#16
0
 public override void FetchCamera()
 {
     base.FetchCamera();
     if (MainCamera != null)
     {
         RTSCamera = MainCamera.GetComponentInChildren <RTSCamera>();
         if (RTSCamera == null)
         {
             RTSCamera = MainCamera.gameObject.AddComponent <RTSCamera>();
         }
     }
 }
示例#17
0
    void Start()
    {
        rtsCamera = Camera.main.GetComponent <RTSCamera>();
        outline   = Camera.main.GetComponent <RenderBlurOutline>();

        var temp = rocksTransform.GetComponentsInChildren <CharacterStatus>();

        foreach (var c in temp)
        {
            rocks.Add(c);
        }

        RoundManager.GetInstance().GameStarted += OnGameStarted;
    }
示例#18
0
    public void OnConfirm()
    {
        if (selectedUnits.Count > 0 && squadCost <= MaxSquadCost)
        {
            ClientNetworkManager.Instance.SendSquadSelection(selectedUnits.Select(x => x.SelectedPlayerUnit).ToList());

            CloseMenu();

            RTSCamera rtsCam = FindObjectOfType <RTSCamera>();
            if (rtsCam != null)
            {
                rtsCam.RefocusOn(ClientGameManager.Instance.TeamSpawns[ClientGameManager.Instance.MyPlayer.teamId].transform.position);
            }
        }
    }
示例#19
0
文件: AIPlayer.cs 项目: gczxcyd/XDD
    //AI
    public override void Play(RoundManager roundManager)
    {
        rtsCamera = Camera.main.GetComponent <RTSCamera>();
        outline   = Camera.main.GetComponent <RenderBlurOutline>();

        if (AI)
        {
            roundManager.RoundState = new RoundStateAITurn(roundManager);
            StartCoroutine(Play());
        }
        else
        {
            roundManager.RoundState = new RoundStateWaitingForInput(roundManager);
        }
    }
示例#20
0
	void Awake()
	{
		if (instance == null)
			instance = this;
		else{
			Destroy(gameObject);
			Debug.LogError("There were two tactical cameras");
		}

		tacticalCamera = GetComponent<Camera> ();
		offset = tacticalCamera.transform.position;
		rtsCamControls = GetComponent<RTSCamera> ();
		normalRadar = GameObject.Find ("Camera (Radar)");
		player = GameObject.FindGameObjectWithTag ("PlayerFighter");

		DrawMapLines();
	}
示例#21
0
    public void InitializeSettings()
    {
        camera = Camera.main.GetComponent <RTSCamera>();

        int invertPan = PlayerPrefs.GetInt(CameraSettings.Instance.RTS_INVERT_PAN);

        if (invertPan == 1)
        {
            invertPanField.isOn = true;
        }
        else
        {
            invertPanField.isOn = false;
        }
        panSmoothField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_PAN_SMOOTH);
        panInputField.text   = PlayerPrefs.GetString(CameraSettings.Instance.RTS_PAN_INPUT);
        distanceField.value  = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_DISTANCE);
        int allowZoom = PlayerPrefs.GetInt(CameraSettings.Instance.RTS_ALLOW_ZOOM);

        if (allowZoom == 1)
        {
            allowZoomField.isOn = true;
        }
        else
        {
            allowZoomField.isOn = false;
        }
        zoomSmoothField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_ZOOM_SMOOTH);
        zoomStepField.value   = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_ZOOM_STEP);
        maxZoomField.value    = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_MAX_ZOOM);
        minZoomField.value    = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_MIN_ZOOM);

        xRotationField.value    = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_X_ROTATION);
        yOrbitSmoothField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.RTS_Y_ORBIT_SMOOTH);
        int allowOrbit = PlayerPrefs.GetInt(CameraSettings.Instance.RTS_ALLOW_ORBIT);

        if (allowOrbit == 1)
        {
            allowOrbitField.isOn = true;
        }
        else
        {
            allowOrbitField.isOn = false;
        }
        orbitInputField.text = PlayerPrefs.GetString(CameraSettings.Instance.RTS_ORBIT_INPUT);
    }
示例#22
0
    //private Vector3 curvePosition;
    //private Vector3 curveDestination;
    //private float curveHeight = 0.25f;


    public void SetMovement(List <Vector3> path, Transform character)
    {
        this.character = character;

        camera = Camera.main.GetComponent <RTSCamera>();

        //audio = character.GetComponent<AudioSource>();
        Pos                      = path;
        moveState                = MoveState.startPoint;
        startPosition            = character.position;
        startRotation            = character.rotation;
        animator                 = character.GetComponent <Animator>();
        runningHash              = Animator.StringToHash("isRunning");
        runHash                  = Animator.StringToHash("Run");
        idleHash                 = Animator.StringToHash("Idle");
        animator.applyRootMotion = false;
        animator.SetBool(runningHash, false);
    }
示例#23
0
    internal IEnumerator ActivateAITree(Unit _aiUnit)
    {
        rtsCamera = Camera.main.GetComponent <RTSCamera>();
        outline   = Camera.main.GetComponent <RenderBlurOutline>();

        //init
        aiUnit         = _aiUnit;
        aiTarget       = null;
        moveTarget     = aiUnit.transform.position;
        skillName      = "";
        dodgeSkillName = "";
        finalDirection = "forward";

        //create move Range and Delete() it after AINodeMoveAI
        moveRange = new MoveRange();
        moveRange.CreateMoveRange(aiUnit.transform, false);

        yield return(StartCoroutine(ActionNode(root)));
    }
示例#24
0
    public bool DramaOrFree = false; //it's taken over by AIManager; otherwise =true it's taken over by Drama

    public override void Play(RoundManager roundManager)
    {
        rtsCamera = Camera.main.GetComponent <RTSCamera>();
        outline   = Camera.main.GetComponent <RenderBlurOutline>();

        if (AIControl)
        {
            roundManager.RoundState = new RoundStateAITurn(roundManager);
            if (DramaOrFree)
            {
                StartCoroutine(AIManager.GetInstance().playDrama());
            }
            else
            {
                StartCoroutine(AIManager.GetInstance().playFree(playerNumber));
            }
        }
        else
        {
            roundManager.RoundState = new RoundStateWaitingForInput(roundManager);
        }
    }
示例#25
0
 public void SetUp()
 {
     camera = Substitute.ForPartsOf <RTSCamera>();
 }
示例#26
0
    void Update()
    {
        //target things
        targetSearchTimer += Time.deltaTime;
        reloadTimer       += Time.deltaTime;
        if (target && team != 2)
        {
            rangeToTarget = (target.position - transform.position).magnitude;
            if (rangeToTarget < range)
            {
                nav.enabled = false;
                Vector3 targetDirHor  = new Vector3(target.position.x, transform.position.y, target.position.z) - transform.position;
                float   angleHor      = Vector3.Angle(targetDirHor, transform.forward);
                Vector3 targetDirVert = target.position - gun.position;
                float   angleVert     = Vector3.Angle(targetDirVert, gun.forward);
                if (angleHor < 30 && angleVert < 30 && reloadTimer > reloadTime)
                {
                    moving = false;
                    //fire
                    GameObject shot = (GameObject)Instantiate(RhinoShot, fireLocation.position, gun.rotation);
                    shot.GetComponent <RhinoShotScript>().team = team;
                    reloadTimer = 0f;
                }
                if (angleHor > 1)
                {
                    //turn toward target
                    Quaternion lookAtRotation = Quaternion.LookRotation(new Vector3(target.position.x, transform.position.y, target.position.z) - transform.position);
                    // Will assume you mean to divide by damping meanings it will take damping seconds to face target assuming it doesn't move
                    transform.rotation = Quaternion.Slerp(transform.rotation, lookAtRotation, Time.deltaTime / 1.0f);
                }
                if (angleVert > 1)
                {
                    Quaternion lookAtRotation = Quaternion.LookRotation(target.position - gun.position);
                    gun.rotation = Quaternion.Slerp(gun.rotation, lookAtRotation, Time.deltaTime / 1.0f);
                }
            }
            else
            {
                nav.enabled = true;
            }
        }
        //find targets in range
        //only looks for target every second if it does not already have a target in range.
        if (targetSearchTimer > targetSearchTime && team == 1 && !building && rangeToTarget < range)
        {
            targetSearchTimer = 0f;
            GameObject[] targets       = GameObject.FindGameObjectsWithTag("Enemy");
            int          minRangeIndex = -1;
            float        minRange      = Mathf.Infinity;
            for (int i = 0; i < targets.Length; i++)
            {
                float targetRange = (targets [i].GetComponent <Transform> ().position - transform.position).magnitude;
                if (targetRange < minRange)
                {
                    minRange      = targetRange;
                    minRangeIndex = i;
                }
            }
            if (minRange < range)
            {
                target = targets[minRangeIndex].GetComponent <Transform>();
            }
            else               //<There is no target in range
            {
                target = null;
            }
        }



        //handes movable unit specific things
        if (!building)
        {
            //set animation state
            anim.SetBool("moving", moving);
            //sets moving to false if reached target destination
            if (transform.position == destination)
            {
                moving = false;
            }
            if (moving)
            {
                //turns slowly until facing is within tolerance of desired facing
                Vector3 targetDir = new Vector3(nav.steeringTarget.x, transform.position.y, nav.steeringTarget.z) - transform.position;
                float   angle     = Vector3.Angle(targetDir, transform.forward);
                if (angle < 5.0f)
                {
                    nav.speed = 5f;
                }
                else if (angle < 45.0f)
                {
                    nav.speed = 3.5f;
                }
                else if (angle > 150)
                {
                    nav.speed = 0.5f;
                }
                else
                {
                    nav.speed = 2;
                }
            }
        }

        //if right mouse button is clicked, set the mouse position as the destination for the nav mesh agent.
        if (selected && Input.GetMouseButtonDown(1) && !building && Input.mousePosition.y > RTSCamera.mouseYLowerBound && team == 1)
        {
            if (moving && nav.enabled == true)
            {
                nav.SetDestination(transform.position);
            }
            startPosition = transform.position - camera.GetGroupCenter();
            Vector3 hitPoint = FindHitPoint();
            if (hitPoint != null)
            {
                float x = hitPoint.x;
                float y = hitPoint.y;
                float z = hitPoint.z;
                destination = new Vector3(x, y, z) + startPosition;
                MakeMove();
            }
        }

        //If the unit is within the selection drag box when the left mouse button is released then select the unit
        if (GetComponentInChildren <Renderer>().isVisible&& Input.GetMouseButtonUp(0) && RTSCamera.selecting && team == 1)
        {
            Vector3 camPos = Camera.main.WorldToScreenPoint(transform.position);
            camPos.y = RTSCamera.InvertMouseY(camPos.y);
            bool s;
            if (RTSCamera.selection.width > 0 && RTSCamera.selection.height > 0)
            {
                s = RTSCamera.selection.Contains(camPos);
            }
            else
            {
                s = new Rect(camera.mousePosX, RTSCamera.InvertMouseY(camera.mousePosY), -RTSCamera.selection.width, -RTSCamera.selection.height).Contains(camPos);
            }
            if (s != selected)
            {
                setSelected();
            }
        }

        //unselects the unit if the left mouse button is clicked, can be reselected in the same click
        if (Input.GetMouseButtonDown(0) && selected && team == 1)
        {
            GameObject hitObject = FindHitObject();
            if (hitObject != transform.gameObject)
            {
                setSelected();
            }
        }
    }
示例#27
0
    private StrategyType strategy;            //use which strategy to deal with enemy

    #region Mono
    void Start()
    {
        rtsCamera = Camera.main.GetComponent <RTSCamera>();
        outline   = Camera.main.GetComponent <RenderBlurOutline>();
        enemyList = new List <Unit>();
    }
示例#28
0
 public virtual void Draw(RTSCamera camera)
 {
     CopyMatrix(camera);
     DrawModel(defaultModel, defaultTex, world);
 }
示例#29
0
 protected void CopyMatrix(RTSCamera camera)
 {
     view       = camera.ViewMatrix;
     projection = camera.ProjectionMatrix;
 }
示例#30
0
 public void Start()
 {
     _RTSCamera = this.GetComponentInChildren<RTSCamera>();
     activeCamera = _RTSCamera.camera;
     _followCamera = this.GetComponentInChildren<FollowCamera>();
     _followCamera.gameObject.SetActive(false);
     _player = this.GetComponent<Player>();
 }
示例#31
0
 public void OnEnable()
 {
     cam = Selection.activeGameObject.GetComponent <RTSCamera>();
 }
示例#32
0
 private void Awake()
 {
     instance = this;
 }
示例#33
0
 public override void OnEnable()
 {
     base.OnEnable();
     RTSCamera = MainCamera.GetComponentInChildren <RTSCamera>();
 }