Well i am trying to make a point system script using 3 different scripts. One for opening a door, when enemy dies recieve points, and a point holding script. My player is called Plaer and enemy is called Zombie. Here is my GetPoints script (also script name).
var PointsGUI : GUIText;
var Give = 50;
var hitPoints = 100;
var deadReplacement : Transform;
var dieSound : AudioClip;
private var Player : PointStorage;
function Awake ()
{
Player = GetComponent (PointStorage);
}
function ApplyDamage (damage : float)
{
if (hitPoints <= 0.0)
{
var Points = Player.GetComponen(PointStorage);
if (Points)
{
PointsGUI.text = Points.Pointsrecieve().ToString();
Points = Give( SendMessage to Points += 50);
}
return;
}
hitPoints -= damage;
if (hitPoints <= 0.0)
{
Detonate();
}
}
function Detonate ()
{
Destroy(gameObject);
if (dieSound)
AudioSource.PlatClipAtPoint(dieSound, transform.position);
if(deadReplacement)
{
var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);
CopyTransformRecurse(transform, dead);
}
}
static function CopyTransdformRecurse (src : Transform, dst : Transform)
{
dst.position = src.position;
dst.rotation = src.rotation;
for (var child : Transform in dst)
{
var curSrc = src.Find(child.name);
if (curSrc)
{
CopyTransformRecurse(curSrc, child);
}
}
}
function LateUpdate ()
{
UpdateGUI();
}
function UpdateGui ()
{
if ( PointStorage )
{
PointsGUI.text = Player.Pointsrecieve().ToString();
}
}
Well i am sorry for the really long script. It holds character life and recieving damage and dying mixed with the getting points. The part of it works for dying and respawning dead replacement, but when it sends the point message to the player and gui (to change text). Tell me whats wrong with this one. Now here is the next one, as mentioned earlier, PointStorage the script that saves the points recieved. Its is not so long
var Points = 0;
var savePoints;
var Pointsrecieved = 0;
private var zombie : GetPoints;
function Awake ()
{
Zombie = GetComponent(GetPoints);
}
function Update ()
{
SavePoints();
GetPoints();
}
function GetPoints ()
{
var Give = Zombie.GetComponent(GetPoints);
if ( Give )
{
var PointsRecieved.Find("Give Points") +=;
}
}
function SavePoints ( save )
{
savePointsRecieved;
}
Now this script fails big time not one part of it works, the last function is to save the points, the getpoints function is to recieve the points. Whats wrong with it, can someone help me with it. Now here is the script for buying door to open and buying guns off the wall. Also not so long.
enum CostType {Doorcost = 1000, Weaponcost = 500}
var CostType = CostType.Doorcost;
var Doorcost = 1000;
var Weaponcost = 500;
var weapon : Transform;
private Player : PointStorage;
private var used = false;
function Awake ()
{
Player = GetComponent("PointStorage");
}
function ApplyType ( Player : PointStorage )
{
if (CostType == CostType.Doorcost)
{
var Points : Player = player.GetComponent(PointStorage);
if ( Points )
{
Points.Points -= 1000;
}
}
else if (CostType == CostType.Weaponcost)
{
var Points : Player = player.GetComponent(PointStorage);
if ( Points )
{
Points.Points -= 500;
}
}
}
function Update ()
{
Door();
Weapon();
}
function Door()
{
Destroy(gameObject);
}
function Weapon ()
{
var weapon(Instantiate.weapon, gameObject.Find("machineGun").transform.position, Quaternion.identity);
}
Well i dont know if this script will even work cause i cant test it. One Problem is that one of the problems is dealing with the += & the -= then its saying valid type with Zombie and Player. Oh and this script is called DoorScript (dont ask). give my fixed code starting from these scripts and tell me what the problem was so i can learn from my mistakes. Thank you so much for helping me if you do and sorry if this question was as big as a boat. Bye Bye