Скрипты для FPS
ZedRot Дата: Ср, 07 Ноя 2012, 22:53 | Сообщение # 1
Сообщений: 21
Награды:
0
Репутация:
2
Статус: Offline
Скрипт для смены оружия, всего 4 позиции. Отлично работает. Code
//Script by Dmitry Gorokhov - ZedRot. My WebSait *** Отвечает за переключение оружий #pragma strict var gun1 : GameObject; //Knife var gun2 : GameObject; //Pistol var gun3 : GameObject; //MainGun var gun4 : GameObject; //Granade function Update () { if(Input.GetKeyDown("1")) { gun1.SetActiveRecursively(true); gun2.SetActiveRecursively(false); gun3.SetActiveRecursively(false); gun4.SetActiveRecursively(false); gun1.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } if(Input.GetKeyDown("2")) { gun1.SetActiveRecursively(false); gun2.SetActiveRecursively(true); gun3.SetActiveRecursively(false); gun4.SetActiveRecursively(false); gun2.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } if(Input.GetKeyDown("3")) { gun1.SetActiveRecursively(false); gun2.SetActiveRecursively(false); gun3.SetActiveRecursively(true); gun4.SetActiveRecursively(false); gun3.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } if(Input.GetKeyDown("4")) { gun1.SetActiveRecursively(false); gun2.SetActiveRecursively(false); gun3.SetActiveRecursively(false); gun4.SetActiveRecursively(true); gun4.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } } //Script by Dmitry Gorokhov - ZedRot. My WebSait ***. Отвечает за переключение оружий
Добавлено (07.11.2012, 19:19) --------------------------------------------- Скрипт для оружия. Просмотрите скрипт и поймёте его функции. Code
//Script by Dmitry Gorokhov - ZedRot. My WebSait ***. Стрельба, прицеливание и всё связаное с оружием #pragma strict enum GunTypes { Knife = 0, Pistol = 1, Gun = 2, Granade = 3 } enum BulletDirection{ forX = 0, forY = 1, forZ = 2 } var gunType : GunTypes; var gunName : String; var shellPoint : Transform; var emptyShell : Rigidbody; var delay : float = 0.5; var bullets : int = 20; var bulletsInClip : int = 20; var clips : int = 120; var muzzleFlash : Renderer; var fireSmoke : ParticleRenderer; var fireLight : Light; var fireAnim : AnimationClip; var reloadAnim : AnimationClip; var reloadSound : AudioClip; var runAnim : AnimationClip; var walkAnim : AnimationClip; var standAnim : AnimationClip; var drawAnim : AnimationClip; var drawSound : AudioClip; var fire : AudioClip; var guiStyle : GUISkin; var hud : Texture; var midPoint : Vector3; var aimPoint : Vector3; var mainCam : Camera; var weaponCam : Camera; var zoom : int; var bullet : Rigidbody; var bulletDirection : BulletDirection; var bulletSpeed : float = 40; var bulletSpawn : Transform; @HideInInspector var playerGo : boolean; @HideInInspector var playerRun : boolean; private var mc : float; private var wc : float; private var saveTime : float = 0; function Start() { mc = mainCam.fieldOfView; wc = weaponCam.fieldOfView; animation.AddClip(walkAnim,"walk"); animation.AddClip(runAnim,"run"); animation.AddClip(standAnim,"stand"); animation.AddClip(fireAnim,"fire"); animation.AddClip(reloadAnim,"reload"); animation.AddClip(drawAnim, "draw"); UpWeapon(); } function Reload() { animation.CrossFade("reload"); audio.PlayOneShot(reloadSound); clips-=bulletsInClip; bullets = bulletsInClip; } function UpWeapon() { animation.CrossFade("draw"); audio.PlayOneShot(drawSound); } function Update() { if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow)) { if(Input.GetKey(KeyCode.LeftShift)) { playerRun = true; playerGo = false; } else{ playerRun = false; playerGo = true; } } else{ playerRun = false; playerGo = false; } if(playerRun) { if(!animation.IsPlaying("draw")) { animation.CrossFade("run"); } } else{ if(playerGo) { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("walk"); } } else { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("stand"); } } } if(bullets == 0 && clips > bulletsInClip) { Reload(); } if(Input.GetKeyDown("r") && clips>=bulletsInClip && bullets<bulletsInClip) { Reload(); } if(gunType==0) { if(Input.GetMouseButtonDown(0)) { Fire(); } } if(gunType == 1) { if(Input.GetMouseButton(0)) { Fire(); } } if(gunType == 2) { if(Input.GetMouseButton(0)) { Fire(); } } if(gunType == 3) { if(Input.GetMouseButton(0)) { Fire(); } } if(Input.GetMouseButton(1)) { Aim(); } if(Input.GetMouseButtonUp(1)) { ExitAim(); } } function Aim() { var cz = mc-zoom; var cz2 = wc-zoom; mainCam.fieldOfView = cz; weaponCam.fieldOfView = cz2; transform.localPosition = aimPoint; } function ExitAim() { mainCam.fieldOfView = mc; weaponCam.fieldOfView = wc; transform.localPosition = midPoint; } function Fire() { if(bullets>0 && Time.time > saveTime && !animation.IsPlaying("reload") && !animation.IsPlaying("run")) { audio.PlayOneShot(fire); bullets--; if(emptyShell && shellPoint) { var gilza = Instantiate(emptyShell, shellPoint.position, shellPoint.rotation); gilza.velocity = transform.TransformDirection(10,0,0); } if(bulletDirection == 0) { var bul = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul.velocity = transform.TransformDirection(bulletSpeed,0,0); } if(bulletDirection == 1) { var bul2 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul2.velocity = transform.TransformDirection(0,bulletSpeed,0); } if(bulletDirection == 2) { var bul3 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul3.velocity = transform.TransformDirection(0,0,bulletSpeed); } animation.Rewind("fire"); animation.CrossFade("fire"); saveTime = Time.time + delay; muzzleFlash.enabled = true; fireSmoke.enabled = true; fireLight.enabled = true; Invoke("ExitFire",0.1); } else { ExitFire(); } } function ExitFire() { muzzleFlash.enabled = false; fireSmoke.enabled = false; fireLight.enabled = false; } function OnGUI() { GUI.skin = guiStyle; GUI.DrawTexture(new Rect(0,0,210,40),hud); GUI.Label(new Rect(30,6,250,30)," " + gunName + " : " + bullets + " / " + clips); } //Script by Dmitry Gorokhov - ZedRot. My WebSait *** Стрельба, прицеливание и всё связаное с оружием
Добавлено (07.11.2012, 22:53) --------------------------------------------- В каком языке програмирования написан этот скрипт??? Это скрипт сна из сталкера. Знаю только .js Code
---------------------------------------------------------------------------------------------------- -- Dream manager ---------------------------------------------------------------------------------------------------- -- Author: Oleg Kreptul (Haron) haronk@ukr.net 2005 ---------------------------------------------------------------------------------------------------- function printf() end can_sleep = false dream_prob = -1 type = "all" dream_types = {all = 2} local def_global_regular_probability = 80 local def_regular_probability = 2 local def_regular_type = "normal" class "dream_mgr" function dream_mgr:__init() printf("dream <init>: START INITIALIZATION") local ini = ini_file("misc\\dream.ltx") self.regular = nil self.scenario = {} if ini:section_exist("dreams") then self.regular_probability = def_global_regular_probability if ini:line_exist("dreams", "regular_probability") then local rp = ini:r_float("dreams", "regular_probability") if rp >= 0 or rp <= 100 then self.regular_probability = rp end end if ini:line_exist("dreams", "dream_types") then local rt_str = ini:r_string("dreams", "dream_types") if rt_str then for rt in string.gfind(rt_str, "([%w_]+)") do dream_types[rt] = 1 end end end if ini:line_exist("dreams", "regular") then self.regular = {} local rd_str = ini:r_string("dreams", "regular") if rd_str then for rd_sect in string.gfind(rd_str, "([%w_]+)") do if ini:section_exist(rd_sect) then if ini:line_exist(rd_sect, "dream") then local dream_path = ini:r_string(rd_sect, "dream") local prob = def_regular_probability local tp = def_regular_type if ini:line_exist(rd_sect, "probability") then local p = ini:r_float(rd_sect, "probability") if p >= 0 then prob = p end end if ini:line_exist(rd_sect, "type") then local t = ini:r_float(rd_sect, "type") if dream_types[t] == 1 then tp = t end end self.regular[rd_sect] = {dream_path, prob, tp} else printf("dream <error>: can't find field <dream> in section [%s].", rd_sect) end else printf("dream <error>: can't find section [%s] defined in the field <regular> in section [dreams].", rd_sect) end end end else printf("dream <error>: can't find field <regular> in section [dreams].") end if ini:line_exist("dreams", "scenario") then self.scenario = {} local sd_str = ini:r_string("dreams", "scenario") if sd_str then for sd_sect in string.gfind(sd_str, "([%w_]+)") do if ini:section_exist(sd_sect) then if ini:line_exist(sd_sect, "dream") then local dream_path = ini:r_string(sd_sect, "dream") if ini:line_exist(sd_sect, "cond") then local cond = xr_logic.cfg_get_condlist(ini, sd_sect, "cond", self) local to_regular = nil if ini:line_exist(sd_sect, "to_regular") then local prob = def_regular_probability local tp = def_regular_type local tr = ini:r_string(sd_sect, "to_regular") local at, to, p, t = string.find(tr, "(%d+),(%w+)") p = tonumber(p) if p then prob = p end if dream_types[t] == 1 then tp = t end to_regular = {prob, tp} end self.scenario[sd_sect] = {dream_path, cond, to_regular} else printf("dream <error>: can't find field <cond> in section [%s].", sd_sect) end else printf("dream <error>: can't find field <dream> in section [%s].", sd_sect) end else printf("dream <error>: can't find section [%s] defined in the field <scenario> in section [dreams].", sd_sect) end end end else printf("dream <error>: can't find field <scenario> in section [dreams].") end else printf("dream <error>: can't find section [dreams].") end printf("dream <init>: END INITIALIZATION") end function dream_mgr:name() return "dream_mgr" end function dream_mgr:get_dream() local k, v local dream = nil for k, v in pairs(self.scenario) do local c = xr_logic.pick_section_from_condlist(db.actor, self, v[2].condlist) --printf("dream <sleep>: dream(%s) cond(%s)", k, tostring(c)) if c == "true" or c == "" then dream = k --printf("dream <sleep>: take") break end end if not dream then -- check regular dream local rval = math.random(100) local rp = self.regular_probability if dream_prob >= 0 then rp = dream_prob end if rval < rp and dream_types[type] then local prob_power = 0 for k, v in pairs(self.regular) do if type == "all" or type == v[3] then prob_power = prob_power + v[2] end end if prob_power > 0 then local cur_prob = 0 rval = math.random(prob_power) for k, v in pairs(self.regular) do if type == "all" or type == v[3] then if rval < cur_prob + v[2] then return v[1] else cur_prob = cur_prob + v[2] end end end end end else v = self.scenario[dream] if v[3] then -- put this dream into regular self.regular[dream] = {v[1], v[3][1], v[3][2]} self.scenario[dream] = nil end return v[1] end return "" -- no dreams end ---------------------------------------------------------------------------------------------------- --- Sleep callbacks ---------------------------------------------------------------------------------------------------- local dream_manager = dream_mgr() function can_sleep_callback() -- function must return "can_sleep" to allow actor sleeping, -- otherwise return string_table identifier that describes reason if can_sleep == true then printf("dream <can_sleep_callback>: can_sleep") return "can_sleep" -- registered keyword else printf("dream <can_sleep_callback>: cant_sleep_not_on_solid_ground") return "cant_sleep_not_on_solid_ground" end end function sleep_video_name_callback() -- function returns video file name or empty string return dream_manager:get_dream() end
Сообщение отредактировал ZedRot - Ср, 07 Ноя 2012, 22:56
Сообщение Скрипт для смены оружия, всего 4 позиции. Отлично работает. Code
//Script by Dmitry Gorokhov - ZedRot. My WebSait *** Отвечает за переключение оружий #pragma strict var gun1 : GameObject; //Knife var gun2 : GameObject; //Pistol var gun3 : GameObject; //MainGun var gun4 : GameObject; //Granade function Update () { if(Input.GetKeyDown("1")) { gun1.SetActiveRecursively(true); gun2.SetActiveRecursively(false); gun3.SetActiveRecursively(false); gun4.SetActiveRecursively(false); gun1.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } if(Input.GetKeyDown("2")) { gun1.SetActiveRecursively(false); gun2.SetActiveRecursively(true); gun3.SetActiveRecursively(false); gun4.SetActiveRecursively(false); gun2.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } if(Input.GetKeyDown("3")) { gun1.SetActiveRecursively(false); gun2.SetActiveRecursively(false); gun3.SetActiveRecursively(true); gun4.SetActiveRecursively(false); gun3.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } if(Input.GetKeyDown("4")) { gun1.SetActiveRecursively(false); gun2.SetActiveRecursively(false); gun3.SetActiveRecursively(false); gun4.SetActiveRecursively(true); gun4.SendMessage("UpWeapon",SendMessageOptions.DontRequireReceiver); } } //Script by Dmitry Gorokhov - ZedRot. My WebSait ***. Отвечает за переключение оружий
Добавлено (07.11.2012, 19:19) --------------------------------------------- Скрипт для оружия. Просмотрите скрипт и поймёте его функции. Code
//Script by Dmitry Gorokhov - ZedRot. My WebSait ***. Стрельба, прицеливание и всё связаное с оружием #pragma strict enum GunTypes { Knife = 0, Pistol = 1, Gun = 2, Granade = 3 } enum BulletDirection{ forX = 0, forY = 1, forZ = 2 } var gunType : GunTypes; var gunName : String; var shellPoint : Transform; var emptyShell : Rigidbody; var delay : float = 0.5; var bullets : int = 20; var bulletsInClip : int = 20; var clips : int = 120; var muzzleFlash : Renderer; var fireSmoke : ParticleRenderer; var fireLight : Light; var fireAnim : AnimationClip; var reloadAnim : AnimationClip; var reloadSound : AudioClip; var runAnim : AnimationClip; var walkAnim : AnimationClip; var standAnim : AnimationClip; var drawAnim : AnimationClip; var drawSound : AudioClip; var fire : AudioClip; var guiStyle : GUISkin; var hud : Texture; var midPoint : Vector3; var aimPoint : Vector3; var mainCam : Camera; var weaponCam : Camera; var zoom : int; var bullet : Rigidbody; var bulletDirection : BulletDirection; var bulletSpeed : float = 40; var bulletSpawn : Transform; @HideInInspector var playerGo : boolean; @HideInInspector var playerRun : boolean; private var mc : float; private var wc : float; private var saveTime : float = 0; function Start() { mc = mainCam.fieldOfView; wc = weaponCam.fieldOfView; animation.AddClip(walkAnim,"walk"); animation.AddClip(runAnim,"run"); animation.AddClip(standAnim,"stand"); animation.AddClip(fireAnim,"fire"); animation.AddClip(reloadAnim,"reload"); animation.AddClip(drawAnim, "draw"); UpWeapon(); } function Reload() { animation.CrossFade("reload"); audio.PlayOneShot(reloadSound); clips-=bulletsInClip; bullets = bulletsInClip; } function UpWeapon() { animation.CrossFade("draw"); audio.PlayOneShot(drawSound); } function Update() { if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow)) { if(Input.GetKey(KeyCode.LeftShift)) { playerRun = true; playerGo = false; } else{ playerRun = false; playerGo = true; } } else{ playerRun = false; playerGo = false; } if(playerRun) { if(!animation.IsPlaying("draw")) { animation.CrossFade("run"); } } else{ if(playerGo) { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("walk"); } } else { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("stand"); } } } if(bullets == 0 && clips > bulletsInClip) { Reload(); } if(Input.GetKeyDown("r") && clips>=bulletsInClip && bullets<bulletsInClip) { Reload(); } if(gunType==0) { if(Input.GetMouseButtonDown(0)) { Fire(); } } if(gunType == 1) { if(Input.GetMouseButton(0)) { Fire(); } } if(gunType == 2) { if(Input.GetMouseButton(0)) { Fire(); } } if(gunType == 3) { if(Input.GetMouseButton(0)) { Fire(); } } if(Input.GetMouseButton(1)) { Aim(); } if(Input.GetMouseButtonUp(1)) { ExitAim(); } } function Aim() { var cz = mc-zoom; var cz2 = wc-zoom; mainCam.fieldOfView = cz; weaponCam.fieldOfView = cz2; transform.localPosition = aimPoint; } function ExitAim() { mainCam.fieldOfView = mc; weaponCam.fieldOfView = wc; transform.localPosition = midPoint; } function Fire() { if(bullets>0 && Time.time > saveTime && !animation.IsPlaying("reload") && !animation.IsPlaying("run")) { audio.PlayOneShot(fire); bullets--; if(emptyShell && shellPoint) { var gilza = Instantiate(emptyShell, shellPoint.position, shellPoint.rotation); gilza.velocity = transform.TransformDirection(10,0,0); } if(bulletDirection == 0) { var bul = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul.velocity = transform.TransformDirection(bulletSpeed,0,0); } if(bulletDirection == 1) { var bul2 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul2.velocity = transform.TransformDirection(0,bulletSpeed,0); } if(bulletDirection == 2) { var bul3 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul3.velocity = transform.TransformDirection(0,0,bulletSpeed); } animation.Rewind("fire"); animation.CrossFade("fire"); saveTime = Time.time + delay; muzzleFlash.enabled = true; fireSmoke.enabled = true; fireLight.enabled = true; Invoke("ExitFire",0.1); } else { ExitFire(); } } function ExitFire() { muzzleFlash.enabled = false; fireSmoke.enabled = false; fireLight.enabled = false; } function OnGUI() { GUI.skin = guiStyle; GUI.DrawTexture(new Rect(0,0,210,40),hud); GUI.Label(new Rect(30,6,250,30)," " + gunName + " : " + bullets + " / " + clips); } //Script by Dmitry Gorokhov - ZedRot. My WebSait *** Стрельба, прицеливание и всё связаное с оружием
Добавлено (07.11.2012, 22:53) --------------------------------------------- В каком языке програмирования написан этот скрипт??? Это скрипт сна из сталкера. Знаю только .js Code
---------------------------------------------------------------------------------------------------- -- Dream manager ---------------------------------------------------------------------------------------------------- -- Author: Oleg Kreptul (Haron) haronk@ukr.net 2005 ---------------------------------------------------------------------------------------------------- function printf() end can_sleep = false dream_prob = -1 type = "all" dream_types = {all = 2} local def_global_regular_probability = 80 local def_regular_probability = 2 local def_regular_type = "normal" class "dream_mgr" function dream_mgr:__init() printf("dream <init>: START INITIALIZATION") local ini = ini_file("misc\\dream.ltx") self.regular = nil self.scenario = {} if ini:section_exist("dreams") then self.regular_probability = def_global_regular_probability if ini:line_exist("dreams", "regular_probability") then local rp = ini:r_float("dreams", "regular_probability") if rp >= 0 or rp <= 100 then self.regular_probability = rp end end if ini:line_exist("dreams", "dream_types") then local rt_str = ini:r_string("dreams", "dream_types") if rt_str then for rt in string.gfind(rt_str, "([%w_]+)") do dream_types[rt] = 1 end end end if ini:line_exist("dreams", "regular") then self.regular = {} local rd_str = ini:r_string("dreams", "regular") if rd_str then for rd_sect in string.gfind(rd_str, "([%w_]+)") do if ini:section_exist(rd_sect) then if ini:line_exist(rd_sect, "dream") then local dream_path = ini:r_string(rd_sect, "dream") local prob = def_regular_probability local tp = def_regular_type if ini:line_exist(rd_sect, "probability") then local p = ini:r_float(rd_sect, "probability") if p >= 0 then prob = p end end if ini:line_exist(rd_sect, "type") then local t = ini:r_float(rd_sect, "type") if dream_types[t] == 1 then tp = t end end self.regular[rd_sect] = {dream_path, prob, tp} else printf("dream <error>: can't find field <dream> in section [%s].", rd_sect) end else printf("dream <error>: can't find section [%s] defined in the field <regular> in section [dreams].", rd_sect) end end end else printf("dream <error>: can't find field <regular> in section [dreams].") end if ini:line_exist("dreams", "scenario") then self.scenario = {} local sd_str = ini:r_string("dreams", "scenario") if sd_str then for sd_sect in string.gfind(sd_str, "([%w_]+)") do if ini:section_exist(sd_sect) then if ini:line_exist(sd_sect, "dream") then local dream_path = ini:r_string(sd_sect, "dream") if ini:line_exist(sd_sect, "cond") then local cond = xr_logic.cfg_get_condlist(ini, sd_sect, "cond", self) local to_regular = nil if ini:line_exist(sd_sect, "to_regular") then local prob = def_regular_probability local tp = def_regular_type local tr = ini:r_string(sd_sect, "to_regular") local at, to, p, t = string.find(tr, "(%d+),(%w+)") p = tonumber(p) if p then prob = p end if dream_types[t] == 1 then tp = t end to_regular = {prob, tp} end self.scenario[sd_sect] = {dream_path, cond, to_regular} else printf("dream <error>: can't find field <cond> in section [%s].", sd_sect) end else printf("dream <error>: can't find field <dream> in section [%s].", sd_sect) end else printf("dream <error>: can't find section [%s] defined in the field <scenario> in section [dreams].", sd_sect) end end end else printf("dream <error>: can't find field <scenario> in section [dreams].") end else printf("dream <error>: can't find section [dreams].") end printf("dream <init>: END INITIALIZATION") end function dream_mgr:name() return "dream_mgr" end function dream_mgr:get_dream() local k, v local dream = nil for k, v in pairs(self.scenario) do local c = xr_logic.pick_section_from_condlist(db.actor, self, v[2].condlist) --printf("dream <sleep>: dream(%s) cond(%s)", k, tostring(c)) if c == "true" or c == "" then dream = k --printf("dream <sleep>: take") break end end if not dream then -- check regular dream local rval = math.random(100) local rp = self.regular_probability if dream_prob >= 0 then rp = dream_prob end if rval < rp and dream_types[type] then local prob_power = 0 for k, v in pairs(self.regular) do if type == "all" or type == v[3] then prob_power = prob_power + v[2] end end if prob_power > 0 then local cur_prob = 0 rval = math.random(prob_power) for k, v in pairs(self.regular) do if type == "all" or type == v[3] then if rval < cur_prob + v[2] then return v[1] else cur_prob = cur_prob + v[2] end end end end end else v = self.scenario[dream] if v[3] then -- put this dream into regular self.regular[dream] = {v[1], v[3][1], v[3][2]} self.scenario[dream] = nil end return v[1] end return "" -- no dreams end ---------------------------------------------------------------------------------------------------- --- Sleep callbacks ---------------------------------------------------------------------------------------------------- local dream_manager = dream_mgr() function can_sleep_callback() -- function must return "can_sleep" to allow actor sleeping, -- otherwise return string_table identifier that describes reason if can_sleep == true then printf("dream <can_sleep_callback>: can_sleep") return "can_sleep" -- registered keyword else printf("dream <can_sleep_callback>: cant_sleep_not_on_solid_ground") return "cant_sleep_not_on_solid_ground" end end function sleep_video_name_callback() -- function returns video file name or empty string return dream_manager:get_dream() end
Автор - ZedRot Дата добавления - 07 Ноя 2012 в 22:53
seaman Дата: Ср, 07 Ноя 2012, 22:58 | Сообщение # 2
Гуру
Сообщений: 1748
Награды:
10
Репутация:
660
Статус: Offline
Lua
Сообщение Lua Автор - seaman Дата добавления - 07 Ноя 2012 в 22:58
90998 Дата: Пн, 19 Ноя 2012, 19:07 | Сообщение # 3
Сообщений: 94
Награды:
0
Репутация:
5
Статус: Offline
ZedRot,а по чем ты учился на Java Script?
Сообщение ZedRot,а по чем ты учился на Java Script? Автор - 90998 Дата добавления - 19 Ноя 2012 в 19:07
ZedRot Дата: Пн, 03 Дек 2012, 20:58 | Сообщение # 4
Сообщений: 21
Награды:
0
Репутация:
2
Статус: Offline
Dynamic crosshair script от парня с ником OneManArmy Code
@script ExecuteInEditMode() enum preset { none, shotgunPreset, crysisPreset } var crosshairPreset : preset = preset.none; var showCrosshair : boolean = true; var verticalTexture : Texture; var horizontalTexture : Texture; //Size of boxes var cLength : float = 10; var cWidth : float = 3; //Spreed setup var minSpread : float = 45.0; var maxSpread : float = 250.0; var spreadPerSecond : float = 150.0; //Rotation var rotAngle : float = 0.0; var rotSpeed : float = 0.0; private var temp : Texture; private var spread : float; function Update(){ //Used just for test (weapon script should change spread). if(Input.GetKey(KeyCode.K)) spread += spreadPerSecond * Time.deltaTime; else spread -= spreadPerSecond * 2 * Time.deltaTime; //Rotation rotAngle += rotSpeed * Time.deltaTime; } function OnGUI(){ if(showCrosshair && verticalTexture && horizontalTexture){ var verticalT = GUIStyle(); var horizontalT = GUIStyle(); verticalT.normal.background = verticalTexture; horizontalT.normal.background = horizontalTexture; spread = Mathf.Clamp(spread, minSpread, maxSpread); var pivot : Vector2 = Vector2(Screen.width/2, Screen.height/2); if(crosshairPreset == preset.crysisPreset){ GUI.Box(Rect((Screen.width - 2)/2, (Screen.height - spread)/2 - 14, 2, 14), temp, horizontalT); GUIUtility.RotateAroundPivot(45,pivot); GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 2)/2, 14, 2), temp, verticalT); GUIUtility.RotateAroundPivot(0,pivot); GUI.Box(Rect((Screen.width - 2)/2, (Screen.height + spread)/2, 2, 14), temp, horizontalT); } if(crosshairPreset == preset.shotgunPreset){ GUIUtility.RotateAroundPivot(45,pivot); //Horizontal GUI.Box(Rect((Screen.width - 14)/2, (Screen.height - spread)/2 - 3, 14, 3), temp, horizontalT); GUI.Box(Rect((Screen.width - 14)/2, (Screen.height + spread)/2, 14, 3), temp, horizontalT); //Vertical GUI.Box(Rect((Screen.width - spread)/2 - 3, (Screen.height - 14)/2, 3, 14), temp, verticalT); GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 14)/2, 3, 14), temp, verticalT); } if(crosshairPreset == preset.none){ GUIUtility.RotateAroundPivot(rotAngle%360,pivot); //Horizontal GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height - spread)/2 - cLength, cWidth, cLength), temp, horizontalT); GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height + spread)/2, cWidth, cLength), temp, horizontalT); //Vertical GUI.Box(Rect((Screen.width - spread)/2 - cLength, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT); GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT); } } }
Сообщение Dynamic crosshair script от парня с ником OneManArmy Code
@script ExecuteInEditMode() enum preset { none, shotgunPreset, crysisPreset } var crosshairPreset : preset = preset.none; var showCrosshair : boolean = true; var verticalTexture : Texture; var horizontalTexture : Texture; //Size of boxes var cLength : float = 10; var cWidth : float = 3; //Spreed setup var minSpread : float = 45.0; var maxSpread : float = 250.0; var spreadPerSecond : float = 150.0; //Rotation var rotAngle : float = 0.0; var rotSpeed : float = 0.0; private var temp : Texture; private var spread : float; function Update(){ //Used just for test (weapon script should change spread). if(Input.GetKey(KeyCode.K)) spread += spreadPerSecond * Time.deltaTime; else spread -= spreadPerSecond * 2 * Time.deltaTime; //Rotation rotAngle += rotSpeed * Time.deltaTime; } function OnGUI(){ if(showCrosshair && verticalTexture && horizontalTexture){ var verticalT = GUIStyle(); var horizontalT = GUIStyle(); verticalT.normal.background = verticalTexture; horizontalT.normal.background = horizontalTexture; spread = Mathf.Clamp(spread, minSpread, maxSpread); var pivot : Vector2 = Vector2(Screen.width/2, Screen.height/2); if(crosshairPreset == preset.crysisPreset){ GUI.Box(Rect((Screen.width - 2)/2, (Screen.height - spread)/2 - 14, 2, 14), temp, horizontalT); GUIUtility.RotateAroundPivot(45,pivot); GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 2)/2, 14, 2), temp, verticalT); GUIUtility.RotateAroundPivot(0,pivot); GUI.Box(Rect((Screen.width - 2)/2, (Screen.height + spread)/2, 2, 14), temp, horizontalT); } if(crosshairPreset == preset.shotgunPreset){ GUIUtility.RotateAroundPivot(45,pivot); //Horizontal GUI.Box(Rect((Screen.width - 14)/2, (Screen.height - spread)/2 - 3, 14, 3), temp, horizontalT); GUI.Box(Rect((Screen.width - 14)/2, (Screen.height + spread)/2, 14, 3), temp, horizontalT); //Vertical GUI.Box(Rect((Screen.width - spread)/2 - 3, (Screen.height - 14)/2, 3, 14), temp, verticalT); GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 14)/2, 3, 14), temp, verticalT); } if(crosshairPreset == preset.none){ GUIUtility.RotateAroundPivot(rotAngle%360,pivot); //Horizontal GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height - spread)/2 - cLength, cWidth, cLength), temp, horizontalT); GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height + spread)/2, cWidth, cLength), temp, horizontalT); //Vertical GUI.Box(Rect((Screen.width - spread)/2 - cLength, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT); GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT); } } }
Автор - ZedRot Дата добавления - 03 Дек 2012 в 20:58
AIDEN Дата: Пн, 06 Май 2013, 11:24 | Сообщение # 5
Сообщений: 59
Награды:
0
Репутация:
56
Статус: Offline
Я конечно извиняюсь, но разве скрипт *Скрипт для оружия* написал не - Flight Dream Studio - бесплатный скрипт системы оружия, для Unity3D, для новичков и не только. от Алексей Дудкина a.k.a. Alcatraz , не приписуйте себе чужые скрипты, даже если вы поменяли пару функцый. Добавлено (06 Май 2013, 11:24) --------------------------------------------- Вот оригинальный скрипт с сайта www.flight-dream.com
Код
//Flight Dream Studio - бесплатный скрипт системы оружия, для Unity3D, для новичков и не только. от Алексей Дудкина a.k.a. Alcatraz #pragma strict enum GunTypes { Pistol = 0, Gun = 1 } enum BulletDirection{ forX = 0, forY = 1, forZ = 2 } var gunType : GunTypes; var gunName : String; var shellPoint : Transform; var emptyShell : Rigidbody; var delay : float = 0.5; var bullets : int = 20; var bulletsInClip : int = 20; var clips : int = 120; var muzzleFlash : Renderer; var fireSmoke : ParticleRenderer; var fireLight : Light; var fireAnim : AnimationClip; var reloadAnim : AnimationClip; var reloadSound : AudioClip; var runAnim : AnimationClip; var walkAnim : AnimationClip; var standAnim : AnimationClip; var drawAnim : AnimationClip; var drawSound : AudioClip; var fire : AudioClip; var guiStyle : GUISkin; var hud : Texture; var midPoint : Vector3; var aimPoint : Vector3; var mainCam : Camera; var weaponCam : Camera; var zoom : int; var bullet : Rigidbody; var bulletDirection : BulletDirection; var bulletSpeed : float = 40; var bulletSpawn : Transform; @HideInInspector var playerGo : boolean; @HideInInspector var playerRun : boolean; private var mc : float; private var wc : float; private var saveTime : float = 0; function Start() { mc = mainCam.fieldOfView; wc = weaponCam.fieldOfView; animation.AddClip(walkAnim,"walk"); animation.AddClip(runAnim,"run"); animation.AddClip(standAnim,"stand"); animation.AddClip(fireAnim,"fire"); animation.AddClip(reloadAnim,"reload"); animation.AddClip(drawAnim, "draw"); UpWeapon(); } function Reload() { animation.CrossFade("reload"); audio.PlayOneShot(reloadSound); clips-=bulletsInClip; bullets = bulletsInClip; } function UpWeapon() { animation.CrossFade("draw"); audio.PlayOneShot(drawSound); } function Update() { if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow)) { if(Input.GetKey(KeyCode.LeftShift)) { playerRun = true; playerGo = false; } else{ playerRun = false; playerGo = true; } } else{ playerRun = false; playerGo = false; } if(playerRun) { if(!animation.IsPlaying("draw")) { animation.CrossFade("run"); } } else{ if(playerGo) { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("walk"); } } else { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("stand"); } } } if(bullets == 0 && clips > bulletsInClip) { Reload(); } if(Input.GetButtonDown("Reload") && clips>=bulletsInClip && bullets<bulletsInClip) { Reload(); } if(gunType==0) { if(Input.GetMouseButtonDown(0)) { Fire(); } } if(gunType == 1) { if(Input.GetMouseButton(0)) { Fire(); } } if(Input.GetMouseButton(1)) { Aim(); } if(Input.GetMouseButtonUp(1)) { ExitAim(); } } function Aim() { var cz = mc-zoom; var cz2 = wc-zoom; mainCam.fieldOfView = cz; weaponCam.fieldOfView = cz2; transform.localPosition = aimPoint; } function ExitAim() { mainCam.fieldOfView = mc; weaponCam.fieldOfView = wc; transform.localPosition = midPoint; } function Fire() { if(bullets>0 && Time.time > saveTime && !animation.IsPlaying("reload") && !animation.IsPlaying("run")) { audio.PlayOneShot(fire); bullets--; if(emptyShell && shellPoint) { var gilza = Instantiate(emptyShell, shellPoint.position, shellPoint.rotation); gilza.velocity = transform.TransformDirection(10,0,0); } if(bulletDirection == 0) { var bul = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul.velocity = transform.TransformDirection(bulletSpeed,0,0); } if(bulletDirection == 1) { var bul2 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul2.velocity = transform.TransformDirection(0,bulletSpeed,0); } if(bulletDirection == 2) { var bul3 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul3.velocity = transform.TransformDirection(0,0,bulletSpeed); } animation.Rewind("fire"); animation.CrossFade("fire"); saveTime = Time.time + delay; muzzleFlash.enabled = true; fireSmoke.enabled = true; fireLight.enabled = true; Invoke("ExitFire",0.1); } else { ExitFire(); } } function ExitFire() { muzzleFlash.enabled = false; fireSmoke.enabled = false; fireLight.enabled = false; } function OnGUI() { GUI.skin = guiStyle; GUI.DrawTexture(new Rect(0,0,210,40),hud); GUI.Label(new Rect(30,6,250,30)," " + gunName + " : " + bullets + " / " + clips); } //Flight Dream Studio - бесплатный скрипт системы оружия, для Unity3D, для новичков и не только. от Алексей Дудкина a.k.a. Alcatraz
Ну и где разница????
Моя игра - Collect Fruit
Сообщение Я конечно извиняюсь, но разве скрипт *Скрипт для оружия* написал не - Flight Dream Studio - бесплатный скрипт системы оружия, для Unity3D, для новичков и не только. от Алексей Дудкина a.k.a. Alcatraz , не приписуйте себе чужые скрипты, даже если вы поменяли пару функцый. Добавлено (06 Май 2013, 11:24) --------------------------------------------- Вот оригинальный скрипт с сайта www.flight-dream.com
Код
//Flight Dream Studio - бесплатный скрипт системы оружия, для Unity3D, для новичков и не только. от Алексей Дудкина a.k.a. Alcatraz #pragma strict enum GunTypes { Pistol = 0, Gun = 1 } enum BulletDirection{ forX = 0, forY = 1, forZ = 2 } var gunType : GunTypes; var gunName : String; var shellPoint : Transform; var emptyShell : Rigidbody; var delay : float = 0.5; var bullets : int = 20; var bulletsInClip : int = 20; var clips : int = 120; var muzzleFlash : Renderer; var fireSmoke : ParticleRenderer; var fireLight : Light; var fireAnim : AnimationClip; var reloadAnim : AnimationClip; var reloadSound : AudioClip; var runAnim : AnimationClip; var walkAnim : AnimationClip; var standAnim : AnimationClip; var drawAnim : AnimationClip; var drawSound : AudioClip; var fire : AudioClip; var guiStyle : GUISkin; var hud : Texture; var midPoint : Vector3; var aimPoint : Vector3; var mainCam : Camera; var weaponCam : Camera; var zoom : int; var bullet : Rigidbody; var bulletDirection : BulletDirection; var bulletSpeed : float = 40; var bulletSpawn : Transform; @HideInInspector var playerGo : boolean; @HideInInspector var playerRun : boolean; private var mc : float; private var wc : float; private var saveTime : float = 0; function Start() { mc = mainCam.fieldOfView; wc = weaponCam.fieldOfView; animation.AddClip(walkAnim,"walk"); animation.AddClip(runAnim,"run"); animation.AddClip(standAnim,"stand"); animation.AddClip(fireAnim,"fire"); animation.AddClip(reloadAnim,"reload"); animation.AddClip(drawAnim, "draw"); UpWeapon(); } function Reload() { animation.CrossFade("reload"); audio.PlayOneShot(reloadSound); clips-=bulletsInClip; bullets = bulletsInClip; } function UpWeapon() { animation.CrossFade("draw"); audio.PlayOneShot(drawSound); } function Update() { if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow)) { if(Input.GetKey(KeyCode.LeftShift)) { playerRun = true; playerGo = false; } else{ playerRun = false; playerGo = true; } } else{ playerRun = false; playerGo = false; } if(playerRun) { if(!animation.IsPlaying("draw")) { animation.CrossFade("run"); } } else{ if(playerGo) { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("walk"); } } else { if(!animation.IsPlaying("reload") && !animation.IsPlaying("fire") && !animation.IsPlaying("draw")) { animation.CrossFade("stand"); } } } if(bullets == 0 && clips > bulletsInClip) { Reload(); } if(Input.GetButtonDown("Reload") && clips>=bulletsInClip && bullets<bulletsInClip) { Reload(); } if(gunType==0) { if(Input.GetMouseButtonDown(0)) { Fire(); } } if(gunType == 1) { if(Input.GetMouseButton(0)) { Fire(); } } if(Input.GetMouseButton(1)) { Aim(); } if(Input.GetMouseButtonUp(1)) { ExitAim(); } } function Aim() { var cz = mc-zoom; var cz2 = wc-zoom; mainCam.fieldOfView = cz; weaponCam.fieldOfView = cz2; transform.localPosition = aimPoint; } function ExitAim() { mainCam.fieldOfView = mc; weaponCam.fieldOfView = wc; transform.localPosition = midPoint; } function Fire() { if(bullets>0 && Time.time > saveTime && !animation.IsPlaying("reload") && !animation.IsPlaying("run")) { audio.PlayOneShot(fire); bullets--; if(emptyShell && shellPoint) { var gilza = Instantiate(emptyShell, shellPoint.position, shellPoint.rotation); gilza.velocity = transform.TransformDirection(10,0,0); } if(bulletDirection == 0) { var bul = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul.velocity = transform.TransformDirection(bulletSpeed,0,0); } if(bulletDirection == 1) { var bul2 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul2.velocity = transform.TransformDirection(0,bulletSpeed,0); } if(bulletDirection == 2) { var bul3 = Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation); bul3.velocity = transform.TransformDirection(0,0,bulletSpeed); } animation.Rewind("fire"); animation.CrossFade("fire"); saveTime = Time.time + delay; muzzleFlash.enabled = true; fireSmoke.enabled = true; fireLight.enabled = true; Invoke("ExitFire",0.1); } else { ExitFire(); } } function ExitFire() { muzzleFlash.enabled = false; fireSmoke.enabled = false; fireLight.enabled = false; } function OnGUI() { GUI.skin = guiStyle; GUI.DrawTexture(new Rect(0,0,210,40),hud); GUI.Label(new Rect(30,6,250,30)," " + gunName + " : " + bullets + " / " + clips); } //Flight Dream Studio - бесплатный скрипт системы оружия, для Unity3D, для новичков и не только. от Алексей Дудкина a.k.a. Alcatraz
Ну и где разница???? Автор - AIDEN Дата добавления - 06 Май 2013 в 11:24